This file contains 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
<script src="app.js"></script> | |
<script src="OtherService.js"></script> | |
<script src="MyService.js"></script> |
This file contains 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('MyService', ['OtherService', function(OtherService){ | |
this.foo = function(){ | |
OtherService.goo(); | |
} | |
}]); |
This file contains 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 () { | |
function MyService(OtherService) { | |
this.foo = function () { | |
OtherService.goo(); | |
} | |
} | |
MyService.$inject = ['OtherService']; | |
angular.module('app').service('MyService', MyService); | |
})(); |
This file contains 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); |
This file contains 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 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 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 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 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 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); | |
} |