0

I have a website builded with angular. I want to do some debugging in the browser console but i don't know how to actually execute my function.

I tried this :

angular.module('app').run(function(myService) {
    myService.doSomething();
});

But the function is not called.

Magus
  • 14,796
  • 3
  • 36
  • 51
  • 3
    Take a look at [this post](http://stackoverflow.com/questions/15527832/how-can-i-test-an-angularjs-service-from-the-console) – Jax Apr 05 '16 at 09:24

1 Answers1

0

This works - Plunker

JS

var app = angular.module('plunker', [])
  .run(function(myService) {
      myService.doSomething();
  })
  .factory('myService', function () {
    var obj = {};
    obj.doSomething = function () {
      console.log("Hello world");
    }
    return obj;
  });
camden_kid
  • 12,591
  • 11
  • 52
  • 88