javascript - Angular Service is injected into controller, but it appears as an empty object -


i have following angular service.

angular.module('myapp') .service('statusservice', function statusservice() {     var statusservice= {         show: 'off',         on: function() {             this.show = 'on';         },         off: function() {             this.show = 'off';         }     };      return statusservice; }); 

which injected controller, , on function invoked, this:

angular.module('myapp')     .controller('acontroller', function (statusservice) {      statusservice.on();  }) 

but following error.

typeerror: object #<object> has no method 'on' 

you problem if declared multiple service same name in different places, got confused , return {}.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -