We can get whatever service we like and then call an specific method.
var serviceName = angular.element(document.body).injector().get('serviceName');
serviceName.someMethod();| /** | |
| * supplant() does variable substitution on the string. It scans through the string looking for | |
| * expressions enclosed in { } braces. If an expression is found, use it as a key on the object, | |
| * and if the key has a string value or number value, it is substituted for the bracket expression | |
| * and it repeats. | |
| * | |
| * Written by Douglas Crockford | |
| * http://www.crockford.com/ | |
| */ | |
| String.prototype.supplant = function (o) { |
| var createPromiseSpy = function(obj, name, method, $q) { | |
| var createdSpy = jasmine.createSpy(name, obj); | |
| var returnObj = {}; | |
| var promise = {}; | |
| if (typeof(method) === 'string') { | |
| var deferred = $q.defer(); | |
| spyOn(createdSpy, method).and.returnValue(deferred.promise); | |
| promise[method] = deferred; | |
| } |
| // http://stackoverflow.com/questions/20252382/how-to-mock-window-location-replace-in-angularjs-unit-test | |
| describe('whatever', function() { | |
| var $window, whatever; | |
| beforeEach(module('services')); | |
| beforeEach(function() { | |
| $window = {location: { replace: jasmine.createSpy()} }; | |
| module(function($provide) { |
Apache appears to be listening on ::1 but not 127.0.0.1.
$ telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
$ telnet 127.0.0.1 80
Trying 127.0.0.1...
| (function() { | |
| 'use strict'; | |
| describe('controllers', function(){ | |
| var scope, vm, state, $rootScope; | |
| // Initialize the controller and scope | |
| beforeEach(function () { | |
| // Load the controller's module | |
| module('AngularApp'); |
| (function() { | |
| 'use strict'; | |
| angular.module('engageAngularApp') | |
| .filter('searchByNameAndPhone', function(){ | |
| return function(items, searchString){ | |
| if(!searchString){ | |
| return items; | |
| } |
| (function() { | |
| 'use strict'; | |
| angular | |
| .module('myApp') | |
| .config(routeConfig); | |
| /** @ngInject */ | |
| function routeConfig($stateProvider, $urlRouterProvider) { | |
| $stateProvider |
| (function() { | |
| 'use strict'; | |
| angular.module('engageAngularApp') | |
| .config(httpInterceptor); | |
| /** @ngInject */ | |
| function httpInterceptor($httpProvider) { | |
| $httpProvider.interceptors.push('httpInterceptorFactory'); | |
| } |