You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
I think it would be useful today to be able to use more than just strings as keys in Angular.js's injector. I'm already aware that the DI framework written for Angular 2 has this capability.
Now that I've been writing all my app code in ES6 and TS I find myself wanting to use a reference to classes/functions like below.
// Module.jsimportEmailDaofrom'./EmailDao.js';exportdefaultangular.module('org.name',[]).service(EmailDao,EmailDao);// Using a reference token here// EmailList.jsimportEmailDaofrom'./EmailDao.js';exportdefaultclassEmailList{staticget$inject(){return[EmailDao];// Using a reference token here}constructor(emailDao){this.emails=[];emailDao.getForPerson(123).then(emails=>this.emails=emails);}}
In very large apps and very large organizations with a lot of shared modules you will often see hacking in a namespace in the string as a result of the key needing to be a string + there is essentially just one injector per ng1 app. For example .service('org.name.namespace.a', EmailDao). By extending the ng1 DI system to be keys by other tokens, we lose the need to use a string for an injector key and being that it's a reference to specific class/function it's guaranteed to be unique.
Thoughts?
The text was updated successfully, but these errors were encountered:
mikehaas763
changed the title
Proposal extending existing DI framework to allow more than strings for keys
Proposal extend existing DI framework to allow more than strings for keys
Oct 14, 2015
I think it would be useful today to be able to use more than just strings as keys in Angular.js's injector. I'm already aware that the DI framework written for Angular 2 has this capability.
Now that I've been writing all my app code in ES6 and TS I find myself wanting to use a reference to classes/functions like below.
In very large apps and very large organizations with a lot of shared modules you will often see hacking in a namespace in the string as a result of the key needing to be a string + there is essentially just one injector per ng1 app. For example
.service('org.name.namespace.a', EmailDao)
. By extending the ng1 DI system to be keys by other tokens, we lose the need to use a string for an injector key and being that it's a reference to specific class/function it's guaranteed to be unique.Thoughts?
The text was updated successfully, but these errors were encountered: