<custom-input-container>
<input ng-model="myModel1" />
</custom-input-container>
<custom-input-container>
<select ng-model="myModel2" >
</select>
</custom-input-container>
我想要做这样的事情(如果可能的话,我想这个指令通过它在“customInput.js”分离是另一个应用模块可用)看ngModel我的指令内
myApp.directive('customInputContainer',function(){
return{
restrict: 'E',
priority: 0,
link:function(scope,element,attr){
scope.watch->//i want to watch the ngModel of
the thing inside <custom-input-container>
then do console.log('recipe was updated:'+thenewvalue);
}
}
});
注意:每个输入容器只有其中的一个input/select/textarea – anaval
您是否知道'transclude'及其含义? – AranS
可悲的是...我是非常新的angularjs – anaval