ile bir denetleyici yüklemek $ stateProvider ile oclazyload kullanarak sorunları yaşıyorum.
Denetleyicinin .js'nin yönlendirici yapılandırmasına yüklenmesi gerektiğini belirtti ve '', ancak, templateURL'de yüklenen dosyada bir ng denetleyicisi özniteliği olarak kullanılamıyor.
ui-rota yapılandırma:
<div class="" id="" ng-controller="OrdersIndexController">...</div>
Ama yüklediğinde, konsol hata atar:
core
.run(
[ '$rootScope', '$state', '$stateParams',
function ($rootScope, $state, $stateParams) {
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
}
]
)
.config(
[ '$stateProvider', '$urlRouterProvider',
function ($stateProvider, $urlRouterProvider) {
console.info('Routing ...');
$urlRouterProvider
.otherwise('/app/dashboard');
$stateProvider
.state('app', {
abstract: true,
url: '/app',
templateUrl: 'templates/app.html',
})
.state('app.orders', {
abstract: true,
url: '/orders',
templateUrl: 'templates/orders/orders.html',
})
.state('app.orders.index', {
url: '/index',
templateUrl: 'templates/orders/index.html',
resolve: {
deps: ['$ocLazyLoad',
function($ocLazyLoad){
console.info('Path ot order controller in route config',Momento.paths.js + 'controllers/orders/index.js');
return $ocLazyLoad.load([
Momento.paths.js + 'controllers/orders/index.js'
])
}
]
}
})
}
]
)
;
Ve templateURL dosya başlar
<info>orders/index controller loaded controllers/orders/index.js:3
<info>Now I've finished loading the controller/order/index.js config/ui-router.js:69
<info>orders template loaded VM30437:1 (<-- this is the app.orders abstract template with ui-view directive ready for app.orders.index view)
<error>Error: [ng:areq] Argument 'OrdersIndexController' is not a function, got undefined
... <trace>
Yani dosyasıdır yukardaki konsol çıktısı tarafından onaylanan ve geliştirici araçlarındaki ağ sekmesi tarafından doğru şekilde yüklenen, ancak mevcut değil controller olarak kullanmak için templateURL içinde? Denetleyiciyi kullanarak yönlendirici yapılandırmasında takma gereksinimi duyuluyor mu: '' anahtarı mı yoksa şablonda mı? Bu uygulamada (sadece) modüle özel olarak bağlanması gerekiyor mu?
Neyi eksik?
PS:
core
.controller('OrdersIndexController', [
'Model', '$scope', '$window',
function( Model, $scope, $window){
console.info("OrdersIndexController fired");
}
]);
Eğer sorunu çözmek Could Çalışmıyor? Benzer bir sorun var gibi görünüyor. – Sjoerd222888
Hayır, bu projedeki sorunu çözemedim. NOT: Eğer kontrol üniteniz başka bir modülün parçasıysa, Filippe'den gelen yayın iyi olur ... ama eğer modülünüzün kendi modülü gibi çalışmamışsa, bu durum zaten açıklanmış ve yüklenmiştir. Belki de ocLazyLoad ekleyebilir veya uzatabilir ve yeniden yükleyebilir, emin değilim, ama artık Angular fazla kullanmıyorum. Şimdi Ember'i tercih ederim. –