Angular Js:class属性中的onchange on on不起作用 [英] Angular Js : onchange in directive at class attribute is not working
本文介绍了Angular Js:class属性中的onchange on on不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
controldirective.js
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;
});
});
}
}
}
plnkr.co/edit/BFGXr7LNAe0KvQipj9JJ?p=preview
我在车辆年问题上写了一个指令validVehicleyear,这个我想调用年份更改并为Vehicle make设置新选项,但它不起作用。
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.
Class =form-control ** valid-vehicleyear ** ng-not-empty ng-dirty ng-valid-parse ng-valid ng-valid-required ng-touching
推荐答案
您忘记申报指令功能
.directive('validVehicleyear',validVehicleyear)
http://plnkr.co/edit/9bGXO96s0BJVik7VecFU?p=preview
这篇关于Angular Js:class属性中的onchange on on不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文