我正在尝试让我的Angular/Webpack/ocLazyLoad应用程序正常工作。我的应用程序代码如下所示:
var app = angular.module('app', ['oc.lazyLoad', 'ngComponentRouter']);
app.config(function ($locationProvider) {
$locationProvider.html5Mode(true);
});
app.value('$routerRootComponent', 'app');
app.component('app', {
template: [
'<a ng-link="[\'Home\']">Home</a> |',
'<a ng-link="[\'Heroes\']">Heroes</a> |',
'<a ng-link="[\'CrisisCenter\']">Crisis Center</a>',
'<hr>',
'<ng-outlet></ng-outlet>',
].join('\n'),
controller: ['$router', '$ocLazyLoad', function($router, $ocLazyLoad) {
$router.config([
{path: '/', name: 'Home', component: 'home', usaAsDefault: true},
//Heroes Route
{
path: '/heroes/...',
name: 'Heroes',
loader: function () {
// lazy load Heroes
/*return $ocLazyLoad.load([require('heroes.module')])
.then(function () {
return 'heroes';
});*/
}
},
//Crisis Center Route
{
path: '/crisis-center/...',
name: 'CrisisCenter',
loader: function () {
// lazy load CrisisCenter
/*return $ocLazyLoad.load([require('')])
.then(function () {
return 'crisisCenter';
});*/
}
}
]);
}]
});但我收到了$router的未知提供程序错误。代码调试很完美,达到了我代码的特定点,但我无法让它与Webpack一起工作(它在我实现它之前是有效的)
提前感谢!
发布于 2016-09-20 15:22:51
将$router更改为$rootRouter解决了此问题。
https://stackoverflow.com/questions/39452995
复制相似问题