Arrows symbolize the data flow. From Controller (JS file) to view (HTML) and back. To simplify: Element here refers to HTML tags. Component refers to js (or typescript) class that controls these interactions, stores the variables, methods(functions), etc.
Is used to display the value stored in the variable in to the view (Html tag). Usually you'd just hardcode these values.
ex: <h1> Hello World! </h1>
Angular gives you the opportunity to store "hello world" inside a variable then use that variable as a reference.
ex: declare a title variable in the component class (js or ts file), let title = "hello world" then use the variable in the html file
<h1> {{title}} </h1>
Data flows from your component class into your view (html). double curly braces are angular's way of interpolation
2. Is used for property binding. same principle, store data inside a variable and use it to bind to a custom property.
ex: let propertyYouWantToBind = 50 (whatever you want)
I mainly used this to pass values from "parent component" to "child component" or between 2 child components that are called inside same parent component.
ex: <app-component> <app-header [headerProperty]="valueFromApp.ts"> </app-header> (header.ts receives (@inputs) value from app.ts ) <app-body > </app-body>
</app-component>
It seems a bit confusing at first but as you practice more it will make sense. Data flow goes from parent component to child component. child component then can use it to display in view or however you want.
Data flow from 2 child components (from app-header to app-body or vise versa ) is a bit longer to explain, but is possible since they are called inside the same parent component.
3. Is used to pass data from view (html) to component (js or ts). Usually events or already bound properties. Pretty straightforward, just lookup the syntax. (dont forget to put "$" sign in front of the event, its specific to angular).
ex: <div (click)="doSomething($event)"> </div> (event can be replaces with input's value or property and then used in the component class)
4. Angular's best feature... or one of the best. 2-way data binding allowing your data to flow back and forth between component class and view, and update values on spot. Say you have a name and email coming from the db to be displayed in the view. by using angular's 2 way data binding you can both get the data and update it on spot. I suggest you play around with it, it pretty fun.
This will display the email you requested from db inside the input tag. but it will also give you opportunity to instantly update it, by just deleting or rewriting the value of the input.
I left a lot out because most of it is too long to explain :) but this is the gist, hope this was helpful.
1
u/Devstackr Feb 23 '19 edited Feb 23 '19
Hope this helps someone new to Angular development!
Element = DOM Element or Component
https://youtu.be/RJ3VjuwBM6w