Skip to content

Instantly share code, notes, and snippets.

@stryju
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stryju/44627cb99eb1b6455eeb to your computer and use it in GitHub Desktop.
Save stryju/44627cb99eb1b6455eeb to your computer and use it in GitHub Desktop.
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...
};
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();
};
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