Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow useFactory and deps for factory registration #99

Closed
Hotell opened this issue Jun 11, 2016 · 1 comment
Closed

allow useFactory and deps for factory registration #99

Hotell opened this issue Jun 11, 2016 · 1 comment

Comments

@Hotell
Copy link
Member

Hotell commented Jun 11, 2016

till now we didn't support factories registration via provide

this has to change and for legacy reasons provide function can't be used within @Component decorator registration so for these purposes, map provider literals will be implemented and accepted

more info about map literal providers

@Component({
  selector: 'app',
  template: 'hello',
  providers: [{
    provide:'myFactory', 
    deps:['$q'], 
    useFactory: ($q)=>{ return function qWrapper(value){ return $q.resolve(value); } 
  }]
})
class App Component{
  constructor(@Inject('myFactory') private myFactory: (value)=>ng.IPromise<any>){}
  getAsPromise(value){  return this.myFactory(value) }
}
@Hotell
Copy link
Member Author

Hotell commented Jun 26, 2016

closed by #101

@Hotell Hotell closed this as completed Jun 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant