Upload
nexthoughts-technologies
View
123
Download
0
Embed Size (px)
Citation preview
HELLO!I am Hiten Pratap Singh You can find me at https://github.com/hitenpratap/https://hprog99.wordpress.com/[email protected]
Angular 1 to 2 - What’s changed?
✘ Controllers to Components✘ Unidirectional data flow✘ Simplified service model✘ Easier to understand. Easy learning curve✘ Template syntax is kinda same✘ Angular Module✘ $scope✘ jqLite/jQuery
Angular 2 Components
✘ Components are directive with template✘ Angular 2 apps are usually built with
Component✘ No $scope and no more controller✘ Functions/Properties are bound directly from
component
How to create component?
✘ Create a class✘ Import the Component decorator✘ Add Meta-Data like selector, template,
directives etc✘ Export class to be used with other class.
Templates in your component
✘ Templates contains the HTML code which gets rendered on browser
✘ Can be placed inside @Component or referenced as a separate file
Styling your component
✘ Style declared in @Component will only be valid for that component only
✘ Can be added directly or referenced as separate file(s).
Ways to bind component to template
✘ Interpolation Expressions✘ Property Binding✘ Event Binding✘ ngModel
Event Binding
✘ Bind directly to events on DOM model using ()✘ Again power just can’t be described in words
ngModel
✘ Allows two way data binding✘ Follows uni-directional data flow concepts✘ Demo to be followed
Child Components
✘ Exist within another Component called Parent Component
✘ To make a child component just make it and tell its parent about it. SIMPLE!!!
Binding Parent TO Child via @Input
✘ Means binding data from parent to child✘ Usually involved two steps:
✗Add property to child and decoarte it with @Input decorator.✗Bind the parent property to child using [] syntax.
Event Emitting and @Output
✘ Child to parent communication is achieved by @Output and Event Emitting together.
Services
✘ Services are best to perform CRUD opeartions✘ Keep main processing part separate from
Components.
THANKS!Any questions?You can find me at:https://github.com/hitenpratap/ https://hprog99.wordpress.com/ [email protected]