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