【发布时间】:2014-02-27 05:15:09
【问题描述】:
我有一个角度指令 esResize,但在隔离范围上使用双向绑定时遇到问题。
window.estimation.directive('esResize', function() {
return {
restrict:'C',
scope: {
pointGrid: '='
},
template: "<h2>{{ pointGrid }}</h2><ul><li ng-repeat='card in pointGrid track by $id(card)'>{{ card }}</li></ul>",
controller: function($scope) {
$scope.shiftTicket = function() {
$scope.pointGrid.push("New Ticket");
};
},
link: function(scope, element, attrs) {
var height;
element.resizable({
grid: [ 10, 20 ],
handles: "n, s",
start: function(event, ui) {
//initialize method
},
resize: function(event, ui) {
scope.shiftTicket();
}
});
}
};
});
当resize 被触发时,pointGrid 在我将其输出到控制台时将“新票证”推送给它。但是,模板不会更新。我是否误解了绑定如何链接到视图,或者这里还有其他东西在起作用?
编辑:视图中的 pointGrid 只是一个数组。
【问题讨论】:
标签: javascript angularjs angularjs-directive angularjs-ng-repeat