小编Lus*_*116的帖子

ngMessages在指令模板中不起作用

我的ngMessages在我的指令模板中不起作用!

我有一个指令myInput与模板和链接功能,模板函数内部创建一个包模板字符串<label><input>.

在Link函数中,我使用require: '^form'FormController并检索表单名称.然后我ngMessages在包裹的元素之后放置一个块.

    (function () {
        'use strict';

        angular
            .module('app.components')
            .directive('myInput', MyInput);

        /*@ngInject*/
        function MyInput($compile, ValidatorService, _, LIST_OF_VALIDATORS) {
            return {
                require: '^form',
                restrict: 'E',
                controller: MyInputController,
                controllerAs: 'vm',
                bindToController: true,
                template: TemplateFunction,
                scope: {
                    label: '@',
                    id: '@',
                    value: '=',
                    validateCustom: '&'
                },
                 link: MyInputLink

            };

            function MyInputController($attrs) {
                var vm = this;
                vm.value = '';
                vm.validateClass = '';
                vm.successMessage = '';
                vm.errorMessage = '';
            }

            function TemplateFunction(tElement, …
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-directive ng-messages

5
推荐指数
1
解决办法
1711
查看次数