我是Angularjs的新手。有人可以帮助找到这个问题吗?双重绑定在这个例子中不起作用。双向绑定在此示例中不起作用
http://jsfiddle.net/gM2Hg/120/
<body ng-app="animateApp">
<br/> the watch is triggered only on the load of the page, not on subsequent changes to the property "acts"
<div ng-controller="tst">
<input type="button" bn="" acts="acts" value="Add Action" /> {{acts.crop}}
</div>
</body>
var animateAppModule = angular.module('animateApp', [])
animateAppModule.controller('tst', function($scope) {
$scope.acts = {
crop: "test"
};
$scope.$watchCollection('model.acts', function(newValue, oldValue) {
alert("as");
})
})
animateAppModule.directive('bn', function() {
return {
restrict: "A",
scope: {
acts: '='
},
link: function($scope, iElement, iAttrs) {
alert("l");
iElement.click(function() {
alert($scope.acts.crop);
$scope.acts = {
crop: "real"
};
alert($scope.acts.crop);
})
}
}
})
您是否收到错误讯息?做事情呈现? – Makoto