Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs $modal窗口内的指令抛出;“未定义”不是一个函数;_Angularjs_Angular Ui Bootstrap - Fatal编程技术网

Angularjs $modal窗口内的指令抛出;“未定义”不是一个函数;

Angularjs $modal窗口内的指令抛出;“未定义”不是一个函数;,angularjs,angular-ui-bootstrap,Angularjs,Angular Ui Bootstrap,使用ui引导,我有一个非常简单的自定义指令,在页面顶部列出警报。在普通页面上,它就像一个冠军。当我在$modal弹出窗口中使用我的指令时,我在ngRepeatAction中得到“undefined is not a function” 我在主页上的模式背后的指令仍然有效。我可以在模型后面看到它。它只是模式弹出窗口中的一个中断。我做错了什么 模式开放代码: $modal.open({ templateUrl: 'partials/main/servers/serverAut

使用ui引导,我有一个非常简单的自定义指令,在页面顶部列出警报。在普通页面上,它就像一个冠军。当我在$modal弹出窗口中使用我的指令时,我在ngRepeatAction中得到“undefined is not a function”

我在主页上的模式背后的指令仍然有效。我可以在模型后面看到它。它只是模式弹出窗口中的一个中断。我做错了什么

模式开放代码:

$modal.open({
            templateUrl: 'partials/main/servers/serverAuths/edit.html',
            controller: function($scope, $modalInstance) {
                $scope.auth = angular.copy(auth);
                $scope.auth.password = null;

                $scope.saveAuth = function() {
                    Auths.editAuth($scope.auth).then(
                        function(resp) {
                            if (resp.rc===0) {
                                Alerts.addAlert('success', 'Auth `'+$scope.auth.name+'` saved.');
                                _.extend(auth, $scope.auth);
                                $modalInstance.close();
                            } else {
                                Alerts.addAlert('danger', 'Auth `'+$scope.auth.name+'` could not be saved. ' + resp.message, 'serverAuths');
                            }
                        }
                    );
                };

                $scope.resetAuth = function() {
                    $modalInstance.close();
                };
            }
        }).result.then(
                function() {
                    Auths.getAuthList().then(
                        function(resp) {
                            $scope.auths = resp;
                        }
                    );
                }
            );
指令模板:

<div class="alert-wrapper alert-{{ alert.type }}"
 ng-repeat="alert in alerts"
 ng-class="{ 'relative':relative }">
<div class="container">
    <div alert type="alert.type" close="closeAlert($index)">{{alert.msg}}</div>
</div>
</div>
警报工厂:

angular.module('app').factory('Alerts', function($timeout) {
var alerts = [];

function timeoutAlert(a) {
    $timeout(function() {
        a.splice(0, 1);
    }, 2500);
}

var addAlert = function(type, msg) {
    alerts.push({type:type, msg:msg});
    timeoutAlert(alerts);
};

var closeAlert = function(index) {
    alerts.splice(index, 1);
};

var getAlerts = function() {
    return alerts;
};

var killAlert = function(msg) {
    var alert = _.where(alerts, {msg:msg});
    var idx = _.indexOf(alerts, alert[0]);
    if (idx > -1) {
        closeAlert(idx);
    }
};

return {
    addAlert:addAlert,
    closeAlert:closeAlert,
    getAlerts:getAlerts,
    killAlert:killAlert
};
});
angular.module('app').factory('Alerts', function($timeout) {
var alerts = [];

function timeoutAlert(a) {
    $timeout(function() {
        a.splice(0, 1);
    }, 2500);
}

var addAlert = function(type, msg) {
    alerts.push({type:type, msg:msg});
    timeoutAlert(alerts);
};

var closeAlert = function(index) {
    alerts.splice(index, 1);
};

var getAlerts = function() {
    return alerts;
};

var killAlert = function(msg) {
    var alert = _.where(alerts, {msg:msg});
    var idx = _.indexOf(alerts, alert[0]);
    if (idx > -1) {
        closeAlert(idx);
    }
};

return {
    addAlert:addAlert,
    closeAlert:closeAlert,
    getAlerts:getAlerts,
    killAlert:killAlert
};
});