January 2018
Intermediate to advanced
348 pages
8h 17m
English
Binding of data can be done from component to view or from view to component. We saw how event binding can take the DOM event from the view to the component using the (...) syntax. Similarly, we can also use the square brackets [...] property binding to get and set the value from our component to the view. Both cases are still unidirectional, where data flows in one direction. This doesn't imply a one time update, as the change from the component would reflect on the view as and when it keeps occurring. Here's an example, where the userName is read from the component and output in view:
/* Somewhere in the view template */<input [value]="userName" [class.red]="1 === 1">.../* Below is in a corresponding Component */class MyComponent ...
Read now
Unlock full access