<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