Vincent Tang Vincent Tang - 1 month ago 8
AngularJS Question

Angular JS some result doesn't show in Google Chrome but show in FireFox

I have created a SelectedProduct factory to save data from ProductDetailCtrl and retrieve the data in ProductOrder Ctrl

The factory is as below

.factory('SelectedProduct',function(){
var products = {};

return{
addCategory: function(_category){
return products.category = {category: _category};
},
addSelectedProduct: function(_name,_image,_quantity,_price){
return products.item = {name: _name, image: _image,quantity: _quantity,price: _price};
},
getSelectedProduct: function(){
return products.item;
},
getCategory:function(){
return products.category
}
}
})


In my product_detail.html, I save the parameter by ng-click in :

<img ng-src="{{product.image}}" alt="{{product.product_name}}" ng-click="SelectImage((detail.image = product.image),(detail.name = product.product_name),(detail.quantity = product.quantity),(detail.price = product.price))" width="500" height="340">


In ProductDetailCtrl:

SelectedProduct.addCategory($stateParams.categoryName);
$scope.SelectImage = function () {
SelectedProduct.addSelectedProduct($scope.detail.name,$scope.detail.image,$scope.detail.quantity,$scope.detail.price);
};


Then I call the saved data in product_order.html:

<h3>RM {{selectedProduct.price}}</h3>


My ProductOrderCtrl:

$scope.selectedProduct = SelectedProduct.getSelectedProduct();
var categoryName = SelectedProduct.getCategory();


BUT the output only can't show in chrome browser, it works fine in my device, and other browsers. I just wondering why would it be like this. Any idea and reason about this problem?

Note:
Other data like name, image link works fine in chrome but just the price in 00.00 format can't show. the price retrieved from MySQL online and is stored in varchar.

Result from Chrome

This is the output from Google Chrome

This is the output from FireFox

Result from FireFox

Answer

There must be some caching in Google Chrome, try Empty Cache and Hard Reload option which can be performed in developer mode, by a simple right click on refresh button!