Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
92
rated 0 times [  95] [ 3]  / answers: 1 / hits: 17609  / 10 Years ago, tue, march 11, 2014, 12:00:00

In one of my angular application I will get the values when I pass the key in ng-repeat.



Here each rows in rowsdata has values like 'my file1 data', 'my file2 data', 'my file3 data'



But I need to pass it as 'myfile1data', 'myfile2data', 'myfile3data'



When I used rows.replace(' ','') it is removing only the first space like 'myfile1 data', 'myfile2 data', 'myfile3 data'



<tr ng-repeat=data in datas> 
<td ng-repeat=rows in rowdatas>{{data[rows.replace(' ','')]}}</td>
</tr>


EDIT



But when I use



<td ng-repeat=rows in rowdatas>{{data[rows.replace(/ /g,'')]}}</td>


I got



Error: a is not a function OPERATORS[/]@http://loclhost/jcp_standardwork/secure/scripts/vendor/angular/a‌​ngular.js:5959 OPERATORS[/]@http://loclhost/jcp_standardwork/secure/scripts/vendor/angular/a‌​ngular.js:5959 binaryFn/<@http://loclhost/jcp_standardwork/secure/scripts/vendor/angular/angul‌​ar.js:6292 


Can anyone show me some solution for this?


More From » angularjs

 Answers
52

Try this:



rows.replace(/ /g,'')
<tr ng-repeat=data in datas>
<td ng-repeat=rows in rowdatas>{{rows.replace(/ /g,'')}}</td>
</tr>


Rows should already be the list item. For details of replace check here; it has actually nothing to do with angular.


[#72051] Monday, March 10, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
donovanjasek

Total Points: 465
Total Questions: 103
Total Answers: 113

Location: Saint Vincent and the Grenadines
Member since Thu, Oct 15, 2020
4 Years ago
;