I am new to AngularJS and want to find an efficient solution for my problem.
I have an array of objects as
var list = [
{listprice: 100, salesprice:100, discount:0},
{listprice: 200, salesprice:200, discount:0},
{listprice: 300, salesprice:300, discount:0},
];
Salesprice can be changed by the user or updated by backend code. My requirement is to watch each of the salesprice for changes(whether UI or backend) and update the corresponding discount for that object only.
I was considering using $watch, but can not understand how to use it to bind to each salesprice in the array and the corresponding function that changes the discount.