When we need to update $scope value from outside such as JQuery AJAX, we need to tell Angular the value had been changed via $scope.$apply()
EX :
$.ajax({
type: "POST",
url: "/Product/handleSearchByModel",
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
if (!result.IsSucceed) {
alert(result.error);
}
else {
$scope.$apply(function () {
$scope.Products = result.Products;
});
}
}
});
沒有留言:
張貼留言