Reputation: 8695
In AngularJS, you could specify @
(instead of =
) in a directive in order to bind to plain text. So, with field: '@'
, you could set the scope.field
value to the string "Hello, World"
with the following HTML:
<my-tag field="Hello, World" />
In Angular 2, I am currently doing the following:
<my-tag [field]="'Hello, World'" />
Notice the single quotes inside the double quotes. Angular 2 is expecting the contents of the attribute to be an expression.
I was wondering if there is a short-hand to treat the attribute values as plain text? This will help avoid the mistake of forgetting the quotes, which I keep making.
Upvotes: 4
Views: 1626
Reputation: 3911
Atleast in the latest version, you can do this in Angular 2 too:
<my-tag field="Hello, World" />
Upvotes: 2