Re:Angular 2 Final Released
by xeromal on Thursday September 15, 2016 @01:30AM
(#12503677)
It's super easy to write a component in ng2. I feel like it's faster, but it's been about a year since I really used ng1.
My favorite thing about ng2 components over ng1 would be the annotations. One annotation turns my component into a component. It links the html template, sets up the services, injects the other components and directives it needs in one simple annotation. In ng1, I remember it being cumbersome to set everything up.
To use a component in your existing app.
You create a new ts file.
Add an annotation.
Write the template inline or in another file.
Reference that ts class in your other components. That's it!
My favorite thing about ng2 components over ng1 would be the annotations. One annotation turns my component into a component. It links the html template, sets up the services, injects the other components and directives it needs in one simple annotation. In ng1, I remember it being cumbersome to set everything up.
To use a component in your existing app. You create a new ts file. Add an annotation. Write the template inline or in another file. Reference that ts class in your other components. That's it!