简体   繁体   中英

Concatenate two values or variables in AngularJS?

I am new with 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 . I want something like 33 but it is showing me 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.

您需要将整数转换为要连接的字符串,然后将结果字符串转换回整数以供以后处理(我想):

parseInt($parent.$index+""+$index)

尝试做类似的事情

ng-init = "imgid={{$parent.$index}}{{$index}}"

尝试这个

ng-init = "imgid={{$parent.$index+' '+$index}}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM