di.js
di.js copied to clipboard
Document TransientScope
I've looked hard at some examples, but I'm struggling to understand what a TransientScope
is.
Could we do with some documentation to cover this?
From @EisenbergEffect's blog:
Instance Scope
In Angular 1.x, all instances in the DI container were singletons. This is the default for Angular 2.0 as well. In order to get different behavior you had to use Services, Providers, Constants, etc. That's some confusing stuff. Fortunately, the new DI has a new, more general and more powerful feature. It now has instance scope control. So, if you want the DI to always create a new instance of a class, every time you ask for one, you can just do this:
@TransientScope
export class MyClass { ... }
Read more: http://eisenbergeffect.bluespire.com/all-about-angular-2-0/
always create a new instance of a class
Perfect explanation. This could be added to https://github.com/angular/di.js/blob/master/docs/terminology.md, if the documentation was expanded.