如何在自定义指令中要求angularJS指令?

时间:2018-12-06 16:37:51

标签: angularjs

所以我试图在我的自定义指令中要求一个angular指令,这给我一个错误

Controller 'ngDisable', required by directive 'testDirective', can't be found!

当我仅尝试测试ng-blur是否唯一时,使用ngDisable会发生相同的错误。有什么想法我做错了吗?

HTML

<input test-directive ng-model="modelValue" ng-blur="ngBlurTest(modelValue)">    

JS

angular.module('testDirectives', [])

.directive('testDirective', [ function() {
    return {
        restrict: 'A',
        require: ['ngModel', 'ngBlur'],
        scope: {
             ngModel: '=',
             ngBlur: '&'
        },

        link: function (scope, element, attrs, ngModelCtrl, test) {
        // Some stuff
        }
    };  
}])

感谢您的帮助!

0 个答案:

没有答案