0
我正嘗試在angularJs中實現自定義指令的雙向綁定。不知何故,它不工作。AngularJS中的自定義指令中的雙向綁定
HTML文件
<div ng-app='myApp'>Outside directive
<input type='text' ng-model='outAttr'>{{outAttr}}</br>
<div my-directive some-attr='outAttr'></div>
</div>
JS文件
var myApp = angular.module('myApp', []);
myApp.directive('myDirective', function() {
return {
restrict: 'A,
replace: true,
scope: {
inAttr: '=someAttr';
},
template: "<div><input type='text' ng-model='inAttr'>\
{{inAttr}}</div>"
}
})
不知怎的,它不工作。這裏是。有人能幫我指出我的錯誤嗎?謝謝。
非常感謝。我覺得 ';'是那裏的主要問題。在添加刪除時,我無意中將「'」從限制中刪除。我的錯! 剛纔我在[小提琴]上工作(http://jsfiddle.net/chandan_jhun/2naL4bam/7/) – Indyarocks 2014-08-28 18:52:53