So I had a problem I needed solved. I had an array object with values. One of those values I needed to update if the value == X.I needed X value to be updated to the Y value. Looking over examples here none of them worked for what I needed or wanted. I finally figured out a simple solution to the problem and was actually surprised it worked. Now normally I like to put the full code solution into these answers but due to its complexity I wont do that here. If anyone finds they cant make this solution work or need more code let me know and I will attempt to update this at some later date to help. For the most part if the array object has named values this solution should work.
$scope.model.ticketsArr.forEach(function (Ticket) {
if (Ticket.AppointmentType == 'CRASH_TECH_SUPPORT') {
Ticket.AppointmentType = '360_SUPPORT'
}
});
Full example below _____________________________________________________
var Students = [
{ ID: 1, FName: "Ajay", LName: "Test1", Age: 20 },
{ ID: 2, FName: "Jack", LName: "Test2", Age: 21 },
{ ID: 3, FName: "John", LName: "Test3", age: 22 },
{ ID: 4, FName: "Steve", LName: "Test4", Age: 22 }
]
Students.forEach(function (Student) {
if (Student.LName == 'Test1') {
Student.LName = 'Smith'
}
if (Student.LName == 'Test2') {
Student.LName = 'Black'
}
});
Students.forEach(function (Student) {
document.write(Student.FName + " " + Student.LName + "<BR>");
});