Can't understand one way binding in Angular2
For Binding Documents Angular2 [target]="expression"
create a one-way binding from the data source to view the targets. But when I do this target="HELLO WORLD"
it works great. Shouldn't the second command give me an error?
target="HELLO WORLD"
gives target
the string value HELLO WORLD
and [target]="expression"
gives target
the variable value expression
.
You can also do [target]="'HELLO WORLD'"
and it will be the same astarget="HELLO WORLD"
You are using two different types of data binding methods provided by AngularJS function
[target] = 'expression'
is a type of property binding. and
target = 'expression'
- an example of string data binding.
Both will work in this scenario. You can read more about them to understand their different use cases.
This article can help you Angular 4 data binding