0

I stumbled across a minor difference and I couldn't figure out what the difference is, if there are any.

e.g:

<kendo-label class="k-display-block" [for]="list" [text]="'find user'"> </kendo-label>

and

<kendo-label class="k-display-block" [for]="list" text="Nutzer finden"> </kendo-label>

notice the double quotation marks in the first line of code.

Thanks a lot in advance

CRoNiC
  • 329
  • 2
  • 4
  • 14
  • also: [What is the difference between parentheses, brackets and asterisks in Angular2?](https://stackoverflow.com/questions/35944749/what-is-the-difference-between-parentheses-brackets-and-asterisks-in-angular2) – pilchard Aug 19 '22 at 08:06

1 Answers1

2

Angular uses property binding, wherin you can bind javascript expressions or properties/functions of a class to attributes and pass them to child component. You can identify the bindings by.

[test] <- property binding (one way binding - from ts updates the html)

(test) <- event binding (one way binding - from html updates the ts)

[(ngModel)] <- both bindings (two way binding - does both the actions of the above bindings)

So in the below expression text is expecting a javascript expression, without the quotes it cannot understand if its a string, it will just error out, trying to find some property called find eventhough its a string.

<kendo-label class="k-display-block" [for]="list" [text]="'find user'"> </kendo-label>

In the below code there is no binding, so by default it will passed as string and its pure html, no angular bindings involved!

<kendo-label class="k-display-block" [for]="list" text="Nutzer finden"> </kendo-label>
Naren Murali
  • 19,250
  • 3
  • 27
  • 54