【发布时间】:2014-01-21 05:30:49
【问题描述】:
我在这里设置了一个指令http://jsfiddle.net/screenm0nkey/8Cw4z/3,它有两个绑定到同一个作用域属性,但由于某种原因,当模型更改时(在输入输入后),指令模板属性中的绑定不会更新。
<test>
<h3>Inner {{count}}</h3>
<input type="text" ng-model="count">
</test>
var App = angular.module('App', []);
App.directive('test', function() {
return {
restrict: 'E',
replace: true,
transclude: true,
template: "<h1>Outer{{count}} <div ng-transclude></div></h1>",
controller: function ($scope) {
$scope.count = 1;
}
};
});
但如果我在标记中移动输入位置,它会起作用并且两个绑定都会更新。
<input type="text" ng-model="count">
<test>
<h3>Inner {{count}}</h3>
</test>
http://jsfiddle.net/screenm0nkey/dCvZk/3
谁能解释为什么包含绑定的输入的位置会影响绑定。我假设在摘要循环期间,无论标记的位置如何,两个绑定的观察者都会更新。
非常感谢
【问题讨论】:
标签: angularjs angularjs-directive