在AngularJS中使用ocLazyLoad加载按需控制器js文件

时间:2016-01-04 06:43:15

标签: angularjs dependency-injection load oclazyload

我在使用ui-router加载按需控制器js文件时遇到问题,并且错误地说:

  

参数'FormController'不是

我的代码是:

'use strict';

var Request = angular.module('Request',['ui.router','oc.lazyLoad'])
    .config(function($stateProvider) {
        $stateProvider.state('form', {
            url: "/form",
            templateUrl: "view/form1.html",
            controller:'FormController as form',
            resolve: {
                form: function( $ocLazyLoad ){
                    return $ocLazyLoad.load(
                        {
                            name:'form',
                            files:['app/controller/FormController.js']
                        }
                    )
                }

        }
    });

我的控制器是:

'use strict';

Request.controller('FormController',function($scope){
    $scope.text = 'This is Form Controller';
})

1 个答案:

答案 0 :(得分:2)

我解决了这个解决方案的问题:

logging.level.org.springframework=ERROR logging.level.com.foo=ERROR 更改为app.controller

https://github.com/ocombe/ocLazyLoad/issues/182