I have a service with a local variable object with events names:
myApp.service('appService', ['$rootScope', function ($rootScope) { var events = { firstEvent: "MyFirstEvent", secondEvent: "MySecondEvent" }; this.doEvent = function(eventName) { // do something... }; }]);
Now I am trying to read events.firstEvent inside a controller:
myApp.controller('myController', ['$scope', 'appervice', function ($scope, appService) { var mydata = appService.events.firstEvent; }]);
The problem I get this error in console:
TypeError: Cannot read property 'firstEvent' of undefined
What I'm doing wrong?
P.S. I also can not access the function doEvent().