I am currently working with a directive that looks like this:
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);
});
}
});
}
};
});
Unfortunately, I have encountered an issue where I am unable to watch for changes. I have a <select>
element in the DOM that updates the value of currentForm
using ngModel
. However, even after selecting an option, the watch
function does not seem to work correctly. Am I overlooking something important here?