ocLazyLoad和angular.bootstrap

时间:2017-12-17 00:00:53

标签: javascript angularjs oclazyload

我想在我的mean-stack网站中添加ocLazyLoad。这是代码:

    .state('kpi', {
        url:'/kpi',
        templateUrl: '/htmls/kpi.html',
        resolve: {
            loadMyCtrl: ['$ocLazyLoad', function ($ocLazyLoad) {
                return $ocLazyLoad.load('/javascripts/kpi-controller.js').then(function () {
                    console.log("done");
                }, function (e) {
                    console.log("error")
                })
            }]
        }}

加载kpi页面返回

bootstrapped
kpi-controller inside
done
Error: [ng:areq] http://errors.angularjs.org/1.5.8/ng/areq?p0=KpiCtrl&p1=not%20aNaNunction%2C%20got%20undefined

错误大约是Error: ng:areq Bad Argument Argument 'KpiCtrl' is not a

KpiCtrlkpi-controller.js中定义,并且控制台中的打印kpi-controller inside显示文件确实已加载。但为什么KpiCtrl仍未被识别?

关于我的代码,有一点特别之处是,在程序开始时,我有

jQuery(document).ready(function () {
    angular.bootstrap(document, ['myweb'])
    console.log("bootstrapped");
})
app = angular.module('myweb', ['ui.router', 'oc.lazyLoad']);

我不理解angular.bootstrap,但似乎应该引导新加载的KpiCtrl以便识别。我尝试在angular.bootstrap(document, ['myweb'])内添加ocLazyLoad,但它显示App already bootstrapped with this element 'document'

有谁知道如何解决这个问题?

0 个答案:

没有答案