1

I have newly included the lazyload library.

var app = angular.module(subdomain, ['ngRoute','ngResource','ngCookies','ngSanitize','angular-md5','mm.foundation','chieffancypants.loadingBar', 'ngAnimate','ui-notification','infinite-scroll','oc.lazyLoad']);

I have loaded the controller in routes page:

 $routeProvider
     .when('/',
     {
        templateUrl: 'app/components/home/home.html',
        access: { requiredLogin: true },
        resolve: {
            lazy: ['$ocLazyLoad', function($ocLazyLoad) {
                return $ocLazyLoad.load([{
                    name: 'app',
                    files: ['dist/home.min.js']
                }]);
            }]
        },
        controller: 'homeController'
    })

and my controller file has:

app.controller("homeController",[....])

I am getting home controller not defined error. If I change the app to angular.module in the controller its working but that's not what I want. Is there any solution for this so I can use app variable?

Bas Slagter
  • 9,831
  • 7
  • 47
  • 78
TorreZz
  • 115
  • 10

2 Answers2

0

Looks like you're having the same issue as this guy: https://stackoverflow.com/a/44414548/1040731

You should reference your controller through the module angular.module('myapp').controller('homeController',...)

Jeff Woodard
  • 647
  • 8
  • 15
0

you can use 'insertBefore' property : set id for

<script id='tag-id' src='app.module.js' type='text/javascript'></script>

then :

$routeProvider
     .when('/',
     {
        templateUrl: 'app/components/home/home.html',
        access: { requiredLogin: true },            
        resolve: {
            lazy: ['$ocLazyLoad', function($ocLazyLoad) {
                return $ocLazyLoad.load([{
                    name: 'app',
                    insertBefore: '#tag-id',
                    files: ['dist/home.min.js']
                }]);
            }]
        },
        controller: 'homeController'
    })
HamidReza
  • 1,726
  • 20
  • 15