2
votes

Just made a simple controller with some injection.

var SimpleProductListController = BaseController.extend({

    _notifications:null,
    _productsModel:null,

    init:function($scope,ProductsModel,$route){
    },    
    defineListeners:function(){
        this._super();            
    },
    destroy:function(){

    }
})
/...

SimpleProductListController.$inject = ['$scope','ProductsModel','$route'];

The console error points to this: http://errors.angularjs.org/1.2.16/ng/areq?p0=SimpleProductListController&p1=not%20aNaNunction%2C%20got%20undefined

Argument 'SimpleProductListController' is not aNaNunction, got undefined

How am I supposed to even debug this? I got batarang but it does nothing here.

1
What is BaseController? This code looks very ember-y, not so much angular-y. - J.Wells
Pretty much lifting from github.com/trochette/Angular-Design-Patterns-Best-Practices but how do you even debug angular? all the errors are meaningless - FlavorScape
Angular's actually usually pretty easy to debug. Errors like this are usually injector-related. So - there is some dependency that needs your SimpleProductListController and your app can't find it anywhere. Maybe you are double declaring your module? eg: var app = angular.module('myModule',[]); /*then somewhere else*/ var app = angular.module('myModule',[/*this second [] parameter will bulldoze/undefine your first module*/]); - J.Wells

1 Answers

5
votes

Basically, Angular is saying that SimpleProductListController is undefined.

When I've gotten that error, it was because I created a controller and tried to inject it into my app but I did not load the file that defines that controller by adding the script tag to my index.html file.