The restrict option is typically set to:
'A' - only matches attribute name
'E' - only matches element name
'C' - only matches class name
'M' - only matches comment
'C' - only matches class name is not working
Class="form-control **valid-vehicleyear** ng-not-empty ng-dirty ng-valid-parse ng-valid ng-valid-required ng-touched"
I created a directive on class associated with element. On change of value i want to call a api and change value of other element. But no change is observed on change.
controlDirective.js
function validVehicleyear($scope, $http) {
return {
restrict: 'C',
scope: {
ngModel: '=',
},
link: function (scope, element, attrs, ngModel) {
element.bind('change', function () {
console.log('here in validVehicleyear');
$http.get('api.php'+scope.ngModel)
.then(function (response) {
$scope.answers.VehicleMake = response.data;
});
});
}
}
}
Vehicle year question has a class valid-vehicleyear. what I am missing here, or is there any other to this on change of answers.vehicleyear.
I wrote a directive validVehicleyear on class at Vehicle year question, this i want to call on change of year and set new options for Vehicle make, but it not working.
plnkr.co/edit/BFGXr7LNAe0KvQipj9JJ?p=preview
I checked around and found that outer/inner directive concept can work here. but not getting how to apply for the dynamic classes.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…