Reputation: 11107
I have an angular app and I'm passing a named function into a controller. The problem is I want to inject a provider into that controller to use. The console gives me TypeError: object is not a function
.
My question is, what's wrong with my syntax? Am I thinking of this the wrong way?
(function() {
'use strict';
angular.module('MyCoolApp.controllers')
.controller('SignInCtrl', ['$scope', 'Avatar', SignInCtrl]);
function SignInCtrl(Avatar) {
var vm = this;
// Error occurs here in reference to creating an instance of Avatar
vm.avatar = new Avatar();
}
})();
Upvotes: 0
Views: 162
Reputation: 77482
First argument is $scope
not Avatar
function SignInCtrl($scope, Avatar) {
var vm = this;
// Error occurs here in reference to creating an instance of Avatar
vm.avatar = new Avatar();
}
Upvotes: 1