Reputation: 13
My question is the following. I have a JSON Object in Angular and I want to replace all ";" with "" from a specific key.
$scope.users = data;
In this case I want to run a loop and replace the values only in
$scope.users[i]['pic'];
Thank you in advance
Upvotes: 1
Views: 4032
Reputation:
$scope.users = [{"uid":"295","pic":"picsprofileIcon.png;"},{"uid":"295","pic":"picsprofileIcon.png;"}]
for(i in $scope.users){
$scope.users[i]['pic'] = $scope.users[i]['pic'].replace(";", "");
}
Upvotes: 0
Reputation: 1238
$scope.users=[{'pic':'df;gd;'},{'pic':'adfgadfgadfgad;adf fdag;'},{'pic':'adfdff; ;;;'}];
angular.forEach($scope.users,function(value, key) {
value.pic= value.pic.replace(/;/g ,'');
},{});
Upvotes: 1