[Fixed] convert string to number angular 2 one way binding

Issue

convert the string to number angular 2 one way binding

[longitude]="loc.location.lng">

loc.location.lng is string i need to convert them to number.but still not working as I expect.
In interpolation it’s working but in this not working.
Thanks

Solution

Make a function which convert the value to float as its location and return the value.

    ConvertString(value){
return parseFloat(value)
}

Call the function in template

[longitude]="ConvertString(loc.location.lng)"

Leave a Reply

(*) Required, Your email will not be published