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

Load on demand controller js file with ocLazyLoad in AngularJS

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

Argument 'FormController' is not a

我的代码是:

'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';
})

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

app.controller更改为angular.module('myApp').controller

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