angularjs,加载模板和控制器部分使用延迟加载

时间:2017-12-13 02:38:03

标签: angularjs

请帮帮我, 使用lazyload在angularjs中加载partialy模板视图和控制器时出现错误。

我收到以下错误消息:

Error: ng:areq
Bad Argument
Argument 'meSygroupController' is not a

如何修复它,当我构建大项目时,所以在加载第一页时一次加载所有javascript控制器是不可能的。以及如何将新控制器应用于现有模块 这里有一些代码:

Filename : angular-app.js
    var colorAdminApp = angular.module('colorAdminApp', [
    'ui.router',
    'ui.bootstrap',
    'oc.lazyLoad'
]);


    colorAdminApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
    $urlRouterProvider.otherwise('/app/dashboard/v2');

    $stateProvider
        .state('app', {
            url: '/app',
            templateUrl: 'demo?page=template/app',
            abstract: true
        })
        .state('app.sys', {
            url: '/system',
            template: '<div ui-view></div>',
            abstract: true
        })
        .state('app.sys.sygroup', {
            url: '/sygroup',
            templateUrl: 'me_sygroup',
            // controller: "meSygroupController",
            data: { pageTitle: 'Master Grup Akses' },
            resolve: {
                service: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        serie: true,
                        files: [
                            'me/meSygroupController.js',
                            'coloradmin/assets/plugins/jquery-jvectormap/jquery-jvectormap-1.2.2.css',
                        ]
                    });
                }]
            }
        })}]);

colorAdminApp.run(['$rootScope', '$state', 'setting', function($rootScope, $state, setting) {
    $rootScope.$state = $state;
    $rootScope.setting = setting;
}]);

这里有模板:

<div ng-controller="meSygroupController"  class="frm">
    <!-- <div> -->
    <ol class="breadcrumb pull-right">
        <li><a href="javascript:;">Beranda</a></li>
        <li><a href="javascript:;">Sistem</a></li>
        <li class="active">Grup User</li>
    </ol>
    <h1 class="page-header">Grup User <small>kelompok otorisasi user...</small></h1>
    <!-- begin panel -->
    <div class="panel panel-inverse">
        <div class="panel-heading">
            <div class="panel-heading-btn">
                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-default" data-click="panel-expand"><i class="fa fa-expand"></i></a>
                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-success" data-click="panel-reload"><i class="fa fa-repeat"></i></a>
                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-warning" data-click="panel-collapse"><i class="fa fa-minus"></i></a>
                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-danger" data-click="panel-remove"><i class="fa fa-times"></i></a>
            </div>
            <h4 class="panel-title">Daftar Grup User</h4>
        </div>
        <div class="panel-body">
            Panel Content Here
        </div>
    </div>
    <!-- end panel -->
</div>

这里是控制器

colorAdminApp.controller('meSygroupController', function($scope, $rootScope, $state) {
    angular.element(document).ready(function() {});
    $scope.test = function() { alert(111); }
    $scope.test();
});

请帮助。 Arif Diyanto

0 个答案:

没有答案