错误:[ng:areq]参数' AddInstallationCtrl'不是一个函数,得到了Object

时间:2017-01-31 12:46:11

标签: angularjs

我找不到我的失败:(

可以帮助我吗?

在我的项目中我有: 控制器负责人

define([
    "./directives/subscribe",
    "./controllers/subscribe",
    "./controllers/script",
    "angular",
    "../models/app.models",
    "../login/app.login",
], function (directives, controllers) {
    var module = angular.module("app.matrix", ["app.models", "app.login"]).config(['$routeProvider', function ($routeProvder) {
        $routeProvder
            .when('/matrix', {
                templateUrl: 'modules/matrix/templates/main.html',
                controller: 'MatrixCtrl'
            })
            .when('/modals', {
                templateUrl: 'modules/matrix/templates/index.html',
                controller: 'AddInstallationCtrl'
            });
    }]);
    module = directives.subscribe(module);
    return controllers.subscribe(module);
    (function () {
        "use strict";
        var app = angular.module('myApp', [
            'ap.lateralSlideMenu',
        ]);
        // service  
        app.service('number', function () {
            return {
                isPositive: function (operationPrice) {
                    return String(operationPrice).indexOf("-") == -1;
                }
            };
        });
    })
 ();
});

controller secondary

define([
    "./matrix",
    "./sidebar",
    "./script"
], function (matrix, sidebar, script) {
    return {
        subscribe: function (app) {

            app.controller('MatrixCtrl', matrix).controller('SidebarCtrl', sidebar);
            app.controller('AddInstallationCtrl', script);
            app.directive('sidebarDirective', function () {
                return {
                    link: function (scope, element, attr) {
                        scope.$watch(attr.sidebarDirective, function (newVal) {
                            if (newVal) {
                                element.addClass('show');
                                return;
                            }
                            element.removeClass('show');
                        });
                    }
                };
            });
            return app;
            }
    };
});

Controller Finaly

define(["angular"], function () {
    // Code goes here
var app = angular.module('myApp', ['ngAnimate', 'ngSanitize']);

    app.config([
        '$compileProvider',
        function ($compileProvider) {
            $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|chrome-extension):/);
            // Angular before v1.2 uses $compileProvider.urlSanitizationWhitelist(...)
        }
    ]);

    app.directive('modalDialog', function ($window, $templateCache, $compile, $http) {
        return {
            restrict: 'EA',
            scope: {
                show: '=',
                modalUser: '=',
                saveUser: '&',
                templateUser: '@'
            },
            replace: true, // Replace with the template below
            //transclude: true, // we want to insert custom content inside the directive
            link: function (scope, element, attrs) {

                $http.get(scope.templateUser, { cache: $templateCache }).success(function (tplContent) {
                    element.replaceWith($compile(tplContent)(scope));
                });

                scope.dialogStyle = {};
                if (attrs.width) {
                    scope.dialogStyle.width = attrs.width + '%';
                    scope.dialogStyle.left = ((100 - attrs.width) / 2) + '%';
                }
                if (attrs.height) {
                    scope.dialogStyle.height = attrs.height + '%';
                    scope.dialogStyle.top = ((100 - attrs.height) / 2) + '%';
                }

                scope.hideModal = function () {
                    scope.show = false;
                };

                scope.clone = function (obj) {
                    if (obj === null || typeof obj !== 'object') {
                        return obj;
                    }
                    var temp = obj.constructor(); // give temp the original obj's constructor
                    for (var key in obj) {
                        temp[key] = scope.clone(obj[key]);
                    }
                    return temp;
                };

                var tempUser = scope.clone(scope.modalUser);

                scope.save = function () {
                    scope.saveUser(scope.modalUser);
                    scope.show = false;
                };

                scope.cancel = function () {
                    scope.modalUser = scope.clone(tempUser);
                    scope.show = false;
                };
            }
            //template: "<div class='ng-modal' ng-show='show'><div class='ng-modal-overlay'></div><div class='ng-modal-dialog' ng-style='dialogStyle'><div class='ng-modal-close' ng-click='hideModal()'>X</div><div class='ng-modal-dialog-content' ng-transclude></div></div></div>"
            //templateUrl: 'my-customer.html'
            //templateUrl: scope.templateUser
        };
    });

    app.controller('AddInstallationCtrl', function ($scope, $window) {
        $scope.modalShown = false;
        $scope.modalShown2 = false;
        $scope.user = { name: "Mara", surname: "Sanchez", shortKey: "1111" };
        $scope.userMod = {};
        $scope.toggleModal = function () {
            $scope.modalShown = !$scope.modalShown;
        };
        $scope.toggleModal2 = function () {
            $scope.modalShown2 = !$scope.modalShown2;
        };
        $scope.saveUser = function (usr) {
            $scope.userMod = usr;
            $window.alert('Desde metodo SALVAR del controller fuera de la ventana: ' + $scope.userMod.shortKey);
        }
    });
});

使用第一个控制器,我声明了url:modules / matrix / templates / index.html

由AddInstallationCtrl驱动程序管理

使用第二个控制器我声明了   该应用程序具有AddInstallationCtrl驱动程序   并且控制器位于变量脚本

App.controller(&#39; AddInstallationCtrl&#39;,脚本);

在最后的控制器中,我声明了我想要执行字母的所有函数

即使是对的,对吧? 因为当你输入modules / matrix / templates / index.html时 它是否告诉我AddInstallationCtrl不是控制器?

0 个答案:

没有答案