I'm needing to replace a character in an object's property value. I'm looping over the array of objects (outputting to console) and retrieving the FeatureUrl property.
I have data coming back from the Svc for that property in the following form:
index.html#/blah
I'm needing to replace the '#' with '#/app' so that my new url comes back in the following form:
index.html#/app/blah
I'm not sure if .replace is the right method to use here, but it is what I have seen suggested. Can someone point me in the right direction?
var localFeatureDetails = function() {
$scope.user = userService.GetUserInformation();
$scope.featureDetails = $scope.user.Features;
var featureUrlRewrite = function () {
var index;
var urlCount;
for (index = 0; index < $scope.featureDetails.length; index++) {
urlCount = $scope.featureDetails[index];
urlCount.FeatureUrl.replace("#","#/app");
console.log(urlCount);
}
};
featureUrlRewrite();
};
localFeatureDetails();
replaceAtis not the right tool here. the location in the string array may change based on the pagereplaceAtwould not work here, OP appears to want a mutable version ofreplace. Unfortunately, strings are immutable so no such method exists. The suggested answer seems to do what you would want.