将字符串转换为数字角2单向绑定 [英] convert string to number angular 2 one way binding
本文介绍了将字符串转换为数字角2单向绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将字符串转换为数字角度2的单向绑定
convert the string to number angular 2 one way binding
[longitude]="loc.location.lng">
loc.location.lng是字符串,我需要将它们转换为number.,但仍无法按我期望的那样工作. 在插值中,它起作用了,但在这种情况下不起作用. 谢谢
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
推荐答案
使函数将值转换为float并返回值.
Make a function which convert the value to float as its location and return the value.
ConvertString(value){
return parseFloat(value)
}
调用模板中的函数
[longitude]="ConvertString(loc.location.lng)"
这篇关于将字符串转换为数字角2单向绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文