Reputation: 1030
I want to replace the Item of an array to the newly created item here is the function
$scope.getPageDetails = function () {
$http.get('/api/privilege/getpagedetails/')
.success(function (data, status) {
$scope.Pages = data;
angular.forEach($scope.Pages, function (value, key) {
var url = "//" + (value.pageUrl);
console.log(url);
$scope.Pages.pageUrl = url;
});
$scope.$applyAsync();
}).error(function () {
});
}
I got the value of pageUrl from array $scope.Pages[] which is recoveryguidance.com
then I added // on the pageUrl var url = "//" + (value.pageUrl);
then it becomes //recoveryguidance.com then how can I push the updated value on array $scope.pages[] in the place of pageUrl.
In short I want to update value from recoveryguidance.com to //recoveryguidance.com of pageUrl column in $scope.pages array.
I am attaching the data also I want to update pageUrl recoveryguidance.com to //recoveryguidance.com.
Please guide me I will be very thankful to you all.
Upvotes: 0
Views: 71
Reputation: 4870
Try this:
angular.forEach($scope.Pages, function (value, key) {
value.pageUrl = "//" + (value.pageUrl);
});
Upvotes: 3