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 コントローラーの前にロードされた場合: 「Argument 'WelcomeCtrl' is not a function, got undefined」というエラーが表示されます。コンテンツのリクエストに 1.5 sa の遅延を設定する必要があります。これは正常ではありません。コンテンツは js の読み込みを待つ必要があります。お願い助けて。