Skip to content

Instantly share code, notes, and snippets.

@stryju

stryju/0_question.js

Last active Aug 29, 2015
Embed
What would you like to do?
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