【发布时间】:2017-04-27 07:38:17
【问题描述】:
我有一个名为“formData”的范围对象。
在我的页面中,用户选择一个数据源并使用 http 提供程序将结果存储到 formData。
$http.get($scope.options.dataSource.transport.read(id))
.success(function (data, status, headers, config) {
$scope.formData = data.value[0];
})
.error(function (data, status, header, config) {
});
然后在我的 html 中,我想使用另一个组件来传递我从 http 请求中检索到的 formData。
<input-text field="Code" caption="Code" dataitem="formData"></input-text>
在输入文本组件中我有
var inputText = {
templateUrl: 'Input-text.tml.html',
bindings: {
field: '@',
caption: '@',
dataitem: '='
},
controller: function ($scope) {
$scope.field = this.field;
$scope.caption = this.caption;
$scope.dataitem = this.dataitem;
}
}
inputText.$inject = ['$scope'];
在 Input-text.tml.html 中
{{dataitem}}
但这不起作用,似乎它不能作为双向绑定起作用,这是:当formData发生变化时,组件不会改变dataitem值。
【问题讨论】:
标签: angularjs http components