Hi I am trying to make requests for my codes.
I have something like
if(hasProduct) {
product.getProduct(, function(product) {
$scope.name = product.name;
$scope.price = product.price;
$scope.region = product.region;
//do other things.
})
} else {
product.getProduct(, function(product) {
$scope.name = product.name; // I need to get product name whether hasProduct is true or false
})
//do something
}
my question is if hasProduct is false, I still need to make a request to get the product name but I don't feel like making two identical requests in different condition is practical. I was wondering if there is a better way to do it. Thanks for the help!
$watchto respond to changes in its fields.