[英]Concatenate two values or variables in AngularJS?
I am new with angularJS. 我是angularJS的新手。 and trying to concatenate two variables?
并尝试连接两个变量?
ng-init = "imgid={{$parent.$index+$index}}"
also tried=> 也尝试过=>
setImgCounter(post.postImages.length,$parent.$index+$index)
here $index=3 and $oarent.$index=3
. 这里
$index=3 and $oarent.$index=3
。 I want something like 33 but it is showing me 6 . 我想要类似33的东西,但显示6。
setImgCounter
is a function and I want to send $parent.$index+$index
as a variable.is there any way to achieve 33 instate of 6. setImgCounter
是一个函数,我想发送$parent.$index+$index
作为变量,有没有办法实现6的33 instate。
您需要将整数转换为要连接的字符串,然后将结果字符串转换回整数以供以后处理(我想):
parseInt($parent.$index+""+$index)
尝试做类似的事情
ng-init = "imgid={{$parent.$index}}{{$index}}"
尝试这个
ng-init = "imgid={{$parent.$index+' '+$index}}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.