Last active
August 29, 2015 14:07
-
-
Save stryju/44627cb99eb1b6455eeb to your computer and use it in GitHub Desktop.
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( 'foo', [] ) | |
.service( 'Foo', service ) | |
.directive( 'foo', directive ); | |
function service() { /* ... */ } | |
function directive() { | |
return { | |
controller : controller, | |
controllerAs : 'fooCtrl', | |
scope : {} | |
} | |
} | |
function controller( Foo ) { | |
this.name = 'my name is'; | |
} | |
controller.prototype.setName = function setName( name ) { | |
// i want to use Foo service here... | |
}; |
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( 'foo', [] ) | |
.service( 'Foo', service ) | |
.directive( 'foo', directive ); | |
function service() { /* ... */ } | |
function directive() { | |
return { | |
controller : controller, | |
controllerAs : 'fooCtrl', | |
scope : {} | |
} | |
} | |
function controller( Foo ) { | |
this.name = 'my name is'; | |
// feels dirty | |
this._Service = Service; | |
} | |
controller.prototype.setName = function setName( name ) { | |
this._Service.doSomething(); | |
}; |
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( 'foo', [] ) | |
.service( 'Foo', service ) | |
.directive( 'foo', directive ); | |
function service() { /* ... */ } | |
function directive() { | |
return { | |
controller : controller, | |
controllerAs : 'fooCtrl', | |
scope : {} | |
} | |
} | |
function controller( Foo ) { | |
this.name = 'my name is'; | |
// performance and memory-efficiency sobs... | |
this.setName = function setName( name ) { | |
Service.doSomething(); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment