Angular + requirejs Controller registry error

0

I'm starting an application with Angular + RequireJs. See below

Main.js

;(function (doc, undefined) {
'use strict';

var $scriptDefault = doc.querySelector('[data-js="script-default"]');
var BASE_URL = $scriptDefault.getAttribute('data-base-url');

require.config({
    baseUrl: '/js',
    paths: {
        jquery: [
            'https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min',
            'vendor/jquery'
        ],
        lodash: 'vendor/lodash',
        angular: '../bower_components/angular/angular.min',
        ngRoute: '../bower_components/angular-route/angular-route.min',
        domReady: '../bower_components/requirejs-domready/domReady',
    },
    shim: {
        'angular': {
            exports: 'angular',
            deps: ['jquery']
        },

        'ngRoute': {
            deps: ['angular']
        },
        'newApp': {
            deps: [
                'angular',
                'ngRoute'
            ]
        }
    },
    deps: [
        // kick start application... see bootstrap.js
        './bootstrap'
    ]
});

})(document);

App.js

'use strict'
define([
    'angular'
], function () {
    var app = angular.module('sisge', ['ngRoute']);
    app.config(function ($routeProvider, $locationProvider) {

        $routeProvider
            .when('/', {
                templateUrl: '../app/modules/dashboard/dashboard.html',
                controller: "DashboardCtrl"
            })
            .when('/usuarios', {
                templateUrl: '../app/modules/usuarios/list.html',
                controller: 'ListUsuarioCtrl',
            })
            .when('/ligas', {
                templateUrl: '../app/modules/ligas/list.html',
                controller: 'ListLigaCtrl',
            })
            .otherwise ({ redirectTo: '/' });

        $locationProvider.html5Mode(true);

    });
return app;
});

bootstrap.js

    define([
        'require',
        'angular',
        'newApp',

    ], function (require, ng) {
        'use strict';

        require(['domReady!'], function (document) {
            ng.bootstrap(document, ['app']);
        });
    });

dashboardCtrl.js

'use strict';
    define([
        '../module'
    ], function (controllers) {
        'use strict';
        controllers.controller('DashboardCtrl', [
            '$scope',

            function ($scope) {
                $scope.message = "Muito bom";
                $scope.text = 'Agora sim dando certo';
                $scope.label = 'caramba';
            }

        ]);
    });

module.js

define([
        'angular'
    ], function (angular) {
        'use strict';
        return angular.module('app.controllers', []);
    });

I'm having the following controller registration error as if it were not loaded, but it appears in network as loaded page:

  

angular.js: 14642 Error: [$ controller: ctrlreg] link $ controller / ctrlreg? p0 = DashboardCtrl

Can anyone help?

    
asked by anonymous 18.08.2017 / 03:50

1 answer

0

You've been missing the Controllers in App.js , you're calling it, but it was not created. For more details, see the documentation .

app.controller('DashboardCtrl', ['$scope', function ($scope) {
    $scope.titulo = 'Dashboard';
}]);
    
18.08.2017 / 04:24