nayan chowdhury
nayan chowdhury

Reputation: 283

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.

Upvotes: 0

Views: 1481

Answers (3)

B.V.S Bharat Kumar
B.V.S Bharat Kumar

Reputation: 222

Try this

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

Upvotes: 1

RaphaMex
RaphaMex

Reputation: 2839

You need to convert your integers to string to concatenate, then the resulting string back to integer for later process (I imagine):

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

Upvotes: 2

raychz
raychz

Reputation: 1195

Try doing something like

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

Upvotes: 1

Related Questions