Inject and invoke
Description
The following code shows how to use Inject and invoke.
Example
<!DOCTYPE html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
<!-- w w w . ja v a2 s.com-->
angular.module('main.app', []).factory('MyService', ['$http', function ($http) {
return new function () {
this.GetName = function () {
return "MyName";
};
};
}]);
angular.injector(['ng', 'main.app']).invoke(function (MyService) {
console.log(MyService.GetName());
});
</script>
</head>
<body>
</body>
</html>