angularAMD:视图不等待加载JS(angularAMD: view does not wai

2019-10-21 05:06发布

我有问题,angularAMD。 Main.js:

require.config({
    baseUrl: "/assets/static/app",
    paths: {
        app:                'app',
        angular:            '../angular/angular',
        angularAMD:         '../require/angularAMD',
        angularRoute:       '../angular/angular-route',

        angularRedactor:    '../angular/angular-redactor',
        angularUpload:      '../angular/angular-upload',
        angularSanitize:    '../angular/angular-sanitize',
        angularAnimate:     '../angular/angular-animate',
        angularBootstrap:   '../angular/angular-bootstrap',

        jquery:             '../jquery/jquery.min',
        bootstrap:          '../bootstrap/bootstrap.min',

    },
    shim: {
        bootstrap:          ['jquery'],
        angularAMD:         ['angular'],
        angularRoute:       ['angular'],    
        angularBootstrap:       ['angular','bootstrap'],
        angularAnimate:         ['angular'],
        angularSanitize:        ['angular'],

    },
    deps: ['app']
});

App.js:

define(
    ['angularAMD','angularRoute','angularBootstrap','angularSanitize','angularAnimate'], function (angularAMD) {

    var app = angular.module("app", ['ngRoute','ngBoostrap','ngSanitize','ngAnimate']);

    app.config(function($locationProvider, $logProvider) {
        $locationProvider.html5Mode(true);
        $logProvider.debugEnabled(true);
    });

    //Настройка роутов
    app.config(function($routeProvider) {

    $routeProvider
           .when('/',
                    angularAMD.route({
                        templateUrl: '/welcome',
                        controller: 'WelcomeCtrl',
                        controllerUrl: 'controllers/guest/welcome'
                    })
               )
            .when('/news',
                angularAMD.route({
                    templateUrl: '/news',
                    controller: 'NewsCtrl',
                    controllerUrl: 'controllers/guest/news'
                })
            )
            .when('/news/:post_url',
                angularAMD.route({
                    templateUrl:  function(params){return '/news/post'},
                    controller: 'NewsPostCtrl',
                    controllerUrl: 'controllers/guest/news_post'
                })
            )
            .when('/page/:page_url',
                angularAMD.route({
                    templateUrl:function(params){ return '/page/'+params.page_url},
                    controller: 'PageCtrl',
                    controllerUrl: 'controllers/guest/page'
                })
            )
            .otherwise({redirectTo: '/'});

    });

    app.run();

    return angularAMD.bootstrap(app);
});

Yii框架:

public function render($view,$data=null,$return=false)
    {
        if (strpos($_SERVER['HTTP_ACCEPT'],"application/json") === 0){

            $path_view = '/';
            $path_view .= $this->id.'/'.$view;
            sleep(1.5);//crutches =(
            $this->renderPartial($path_view, $data);
            Yii::app()->end();
        } else {
            parent::render($view,$data,$return);
        }
    }

如果内容JS控制之前加载:我有错误“参数‘WelcomeCtrl’不是一个函数,得到了不确定的”。 我必须把1.5 SA延迟上content.This的要求是不正常的。 内容必须等待加载JS。 请帮帮我。

文章来源: angularAMD: view does not wait for loading js
标签: angular-amd