AngularJs - Приложение с несколькими модулями - PullRequest
0 голосов
/ 17 января 2019

Я немного застрял. Я пытаюсь написать свое угловое приложение, следуя этой рекомендации: https://github.com/johnpapa/angular-styleguide/tree/master/a1/i18n

Но у меня есть сообщение об ошибке: angular_v1.7.5.min.js: 127 Ошибка: [$ controller: ctrlreg] http://errors.angularjs.org/1.7.5/$controller/ctrlreg?p0=initController

Вот мой код:

    //app.js
(function(angular) {
    'use strict';

    angular
        .module('app', [
            'orion.user'
        ])
        .controller('initController', ["$scope", 'orion.user', initController]);

    function initController($scope, user) {
        var vm = $scope;
        console.log(user)
    }})(window.angular);

// user.module.js
(function(angular) {
    'use strict';

    angular
        .module('orion.user', [
            'ngAnimate',
            'ngSanitize',
            'ngRoute'
        ]);

})(window.angular);

//index.html
<!doctype html>
<html lang="fr" ng-app="app" ng-controller="initController">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="theme-color" content="#fff">
    <meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1">
    <meta http-equiv="cache-control" content="max-age=3600" />
    <meta http-equiv="Cache-control" content="public">

    <title>Test</title>  
</head>

<body>

    <script src="src/core/angular_v1.7.5.min.js"></script>
    <script src="src/core/angular-sanitize_v1.7.5.min.js"></script>
    <script src="src/core/angular-animate_v1.7.5.min.js"></script>
    <script src="src/core/angular-route_v1.7.5.min.js"></script>

    <script src="src/user/user.module.js"></script> 
    <script src="src/user/user.factory.js"></script>
    <script src="src/user/user.controler.js"></script>

    <script src="src/core/app.js"></script>

</body>

</html>

App.js - это мое основное приложение с именем "app". Я пытаюсь инициировать вызов вызывающего пользовательского модуля. Может кто-нибудь объяснить мне, что я делаю не так?

Спасибо!

1 Ответ

0 голосов
/ 17 января 2019

Вы не регистрируете свой контроллер должным образом.

попробуй:

   /app.js
(function(angular) {
    'use strict';

    angular
    .module('app', [
        'orion.user'
    ])
    .controller('initController', ["$scope", 'orion.user', initController]);

    function initController($scope, user) {
        var vm = $scope;
        console.log(user)
    }})(window.angular);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...