1

I am trying to get my Angular/Webpack/ocLazyLoad app to work. My app code looks like this:

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';
                });*/
        }

    }

    ]);
 }]

 });

But I get an unkown Provider Error for $router. The code debugs perfect and reaches the specific points of my code, but I can't get it to work with Webpack (it worked before I implemented it)

Thanks in advance!

julesrose
  • 47
  • 9

1 Answers1

0

Changing $router to $rootRoutersolved the issue.

julesrose
  • 47
  • 9