This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| beforeEach(inject(function($compile, $rootScope) { | |
| scope = $rootScope.$new(); | |
| scope.text = 'Hello World'; | |
| element = angular.element("<div upper-case-scope text='text'></div>"); | |
| $compile(element)(scope); | |
| scope.$apply(); | |
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module("app", []) | |
| .service('A', function(B) { | |
| this.data1 = 'a'; | |
| this.foo = function() { | |
| console.log('A.foo:', this.data1, B.data2); | |
| } | |
| }) | |
| .service('B', function(A) { | |
| this.data2 = 'b'; | |
| this.foo = function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .service('B', function($injector) { | |
| this.data2 = 'b'; | |
| this.foo = function() { | |
| console.log('B.foo:', $injector.get('A').data1, this.data2); | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module("app", []) | |
| .service('A', function(DataService) { | |
| this.foo = function() { | |
| console.log('A.foo:', DataService.data1, DataService.data2); | |
| } | |
| }) | |
| .service('B', function(DataService) { | |
| this.foo = function() { | |
| console.log('B.foo:', DataService.data1, DataService.data2); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('utils', []).directive('hover', function() { | |
| return { | |
| restrict: 'E', | |
| template: '<div ng-mouseover="ctrl.over()">HOVER</div>', | |
| controllerAs: 'ctrl', | |
| controller: function() { | |
| this.over = function() { | |
| console.log('over'); | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function dispatchEvent(el, eventType) { | |
| var event = document.createEvent('MouseEvents'); | |
| event.initEvent(eventType, true, true); | |
| el.dispatchEvent(event) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('greet directive spec', function() { | |
| var element; | |
| beforeEach(module('utils')); | |
| beforeEach(inject(function($compile, $rootScope) { | |
| element = angular.element('<hover></hover>'); | |
| $compile(element)($rootScope.$new()); | |
| })); | |
| it('should call console log on mouseover', function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('app',[]) | |
| .directive('dir1',function(){ | |
| return { | |
| template: '<div id="myId">Hello World!</div>', | |
| link: function(scope, element){ | |
| $('#myId').css('color','green'); | |
| } | |
| }; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('app',[]) | |
| .directive('dir1',function(){ | |
| return { | |
| template: '<div id="myId">Hello World!</div>', | |
| link: function(scope, element){ | |
| element.find('#myId').css('color','green'); | |
| } | |
| }; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function MyService(OtherService) { | |
| this.foo = function () { | |
| OtherService.goo(); | |
| } | |
| } | |
| MyService.$inject = ['OtherService']; | |
| angular.module('app').service('MyService', MyService); |