Hi Ahmed,
Do yourself a favor, and drop jQuery for the time you are learning Angular.
$http.get("/api/CustomerService/GetProduct?id=" + id).success(function (data
) {
angular.forEach(data, function (item) { // really? I think its highly
unlikely that an query by id will yield more then 1 result, and if it does,
you have an issue with your server!
//the lines below are all DOM manipulating. This is not how Angualr
works.
$("#Products").val(item.ProductName).trigger('change');
$("#SellPrice").val(item.sell_price).trigger('change');
$("#Stock").val(item.stock).trigger('change');
$("#Quantity").focus(); // for focus you should create a small helper
directive!
});
This can be replaced by:
$http.get("/api/CustomerService/GetProduct?id=" + id).success(function (data
) {
$scope.CurrentItemThatsBeingEdited = data[0]; //if the field names
differ between the view and the result from the server, you might need some
mappings.
})
Regards
Sander
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.