私はこのようなディレクティブがあります。
app.directive('selectedForm', function(MainService) {
return {
scope: {
formName: '=currentForm'
},
restrict: 'E',
link: function($scope, iElm, iAttrs, controller) {
$scope.$watch('formName', function(oldV, newV) {
console.log(iElm);
if (someCondition) {
MainService.getForm($scope.formName).then(function(re) {
iElm.html(re);
});
}
});
}
};
});
をしかし、問題は、私は変更を監視することはできませんです。 DOMの<select>
要素の値がcurrentForm
、ngModel
に変更されています。しかし、オプションを選択しても、watch
関数は機能しません。何か不足していますか?
を、私は見ることができません'$ scope'の変更は...? –
できます。私が言っているのは、コントローラで使うのと同じ方法で '$ watch 'を使うことができないということです。 –
私は別々の指示文を持っています: '