Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

property binding concatenate strings angular

How can I concatenate the below two statements. Both work by oneself.

<app-output [warnMessage]="myvalue | number:'1.0-1'"></app-output>

<app-output [warnMessage]="'TEXT01' | translate"></app-output>

Now I would like to combine both. How can I achieve this? In example something like that:

<app-output [warnMessage]="myvalue | number:'1.0-1' + 'TEXT01' | translate"></app-output>
like image 646
surfspider Avatar asked Aug 16 '18 12:08

surfspider


People also ask

What is property binding in Angular?

Property binding in Angular helps you set values for properties of HTML elements or directives. Use property binding to do things such as toggle button functionality, set paths programmatically, and share values between components.

What is difference between property binding vs string interpolation?

Conclusion. Angular interpolation displays a component property in the view template with double curly braces syntax. Thus, we can show all properties data into view, e.g., string, number, date, arrays, list, or map. Property binding is the technique that will help us bind values to HTML elements' properties.

How do you concatenate strings and variables in TypeScript?

TypeScript | String concat() Method The concat() is an inbuilt function in TypeScript which is used to add two or more strings and returns a new single string. Syntax: string. concat(string2, string3[, ..., stringN]);

Which is the correct syntax for property binding in Angular?

Property binding: Property binding is a one-way mechanism that lets you set the property of a view element. It involves updating the value of a property in the component and binding it to an element in the view template. Property binding uses the [] syntax for data binding.


1 Answers

Try adding some brackets

<app-output [warnMessage]="(myvalue | number:'1.0-1')+('TEXT01' | translate)">
</app-output>
like image 117
nsndvd Avatar answered Oct 10 '22 03:10

nsndvd