Reputation: 176
I am infant in angular. I want to update my label text. This is how I tried.
My html:
<Label class="ad-label" text="{{ labelText }}" textWrap="true"></Label>
My ts :
labelText: any='Month';
I encounter the error
Error: Template parse errors: Can't bind to 'text' since it isn't a known property of 'Label'.
When I use <a class="ad-label" text="{{ labelText }}" textWrap="true"></a>
instead of Label text is updated using labelText: any='Month';
How to update text of label?
Upvotes: 1
Views: 9391
Reputation: 199
please try this
labelText: any='Month'; change to labelText='Month'; in your ts file
or you can use ngModel to two way binding
<Label class="ad-label" [(ngModel)]="labelText" textWrap="true"></Label>
Upvotes: 0
Reputation: 187
If you are trying to bind an attribute to a variable from your .ts file you need to use [square] brackets. Like so:
<Label [text]="labelText"></Label>
Additionally, it's complaining that 'text' is not a property on the Label element. Do you mean to use ion-label?
Upvotes: 0
Reputation: 136144
Since text
property(Input
binding) is not available inside Label
component, you can't use it. Angular is complaining about the same. Actually you should put label
text inside the Label
element.
<Label class="ad-label" textWrap="true">
{{labelText}}
</Label>
Upvotes: 4
Reputation:
This error means that no text
attribute exists on the Label
tag.
That's like using the view box attribute from SVG (<svg viewBox="0 0 100 100"></svg>
) on a idv : it doesn't exist.
I don't know what a Label
is, so I assume it's part of a framework or library. Either try this
<Label class="ad-label" textWrap="true">{{ labelText }}</Label>
Or look at the documentation of your framework / library to see how to add the text to your label.
Upvotes: 1