javascript - Is there a way to pass a variable with curly brace template tags through a method? -


I have ng-repeat where I run ng-if Checks to see if some parameters match between two sets of data, if there is a match, then it updates $ scope with the current match, which is used I can do this to output my template:

  & lt; Div ng-repeat = "repeatedItem in repeatedItems" & gt; & Lt; A href = "" ng-if = "! Match data (repeated itam.itum1, repeated itam.itum2)" & gt; & Lt; Img ng-src = "{{matchedItem.falseImageUrl}}" /> & Lt; / A & gt; & Lt; A href = "" ng-if = "match data (repeated itam.itm1, repeated itam.itm 2)" ng-click = "open (matte idam.ed)" & gt; & Lt; Img ng-src = "{{matchedItem.imageUrl}}" /> & Lt; Time & gt; {{MatchedItem.date}} & lt; / Time & gt; & Lt; Div class = "button-cover" & gt; & Lt; Button class = "btn" & gt; {{MatchedItem.text}} & lt; / Button & gt; & Lt; / Div & gt; & Lt; / A & gt; & Lt; / Div & gt;  

The thinking is that it is necessary to show everything out of repeating , as long as in duplicate items You can show the matched item instead of any other data set.

Everything is fine, except the ng-click = "open (matched item.id) bit. Do not wrap in the matchedItem.id template tag Is done, ng-click is always calling the latest trend of matched items, so for all but for the previous duplicated elements, this is the wrong opening link.

My angular-inexperienced mind has the most obvious solution like ng-click = "open ({{matchedItem.id}}) , but that throws an error. The next idea was like the code of ng-click = "open ({0}): {{matchedItem.id}} - a printf type, but I paradise I did not find any built-in angular solution for it. I also thought about styling {{matchedItem.id}} in particular ( data-id = "{{matchedItem.id} } "?), But I'm not sure how to call that attribute in the law.

Is it possible (possible?) That I just" think fingers "and I Completely about this I'm going to stray ways. Or maybe there is one instruction that I just do not know?

Here is the method:

  $ range MatchData = function (item1, item2) {var isIatAMatch = false; (I = 0; i & lt; $ scope.repeatedItems.length; i ++) for {itemAToMatch = $ scope.repeatedItems [i] .itemA; ItemBToMatch = $ scope.repeatedItems [I] ITMB; If (Itatomato == Item 1 & MFT-Metach == Item 2) {IITAMAP = True; $ Scopmatate item = $ scope. Rep eatedItems [i]; break; }} Return to IITMAAP; }  


Comments