Reputation: 65
I have exported function in separated file
export function sum(population): string {
return population.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}
I am import this function in my component:
import { sum } from '../../shared/utilities/globalFunction'
And how to use this sum in html ?
When i set
<p> {{ sum(variable-with-data) }}
no work...
Upvotes: 2
Views: 931
Reputation: 58039
in html only can use "variables" public in ts, so you need declarea a "variable" (*) and use some like
//in .ts
mysum=sum
//in .html
{{mysum(variable-with-data)}}
Is like another one, you can not use Math in .html but you can use
//in .ts
myMath=Math
//in .html
{{myMat.cos(3.4)}}
(*) I say variable, ,but can be a class, an object a function...
Upvotes: 1