【问题标题】:Angular JS some result doesn't show in Google Chrome but show in FireFoxAngular JS 某些结果未在 Google Chrome 中显示,但在 FireFox 中显示
【发布时间】:2023-03-28 08:35:01
【问题描述】:

我创建了一个 SelectedProduct 工厂来保存 ProductDetailCtrl 中的数据并在 ProductOrder Ctrl 中检索数据

工厂如下

    .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
    }
}
})

在我的 product_detail.html 中,我通过 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">

在 ProductDetailCtrl 中:

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

然后我调用product_order.html中保存的数据:

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

我的 ProductOrderCtrl:

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

但输出只能在 chrome 浏览器中显示,它在我的设备和其他浏览器中运行良好。我只是想知道为什么会这样。关于这个问题的任何想法和原因?

注意: 名称、图片链接等其他数据在 chrome 中工作正常,但无法显示 00.00 格式的价格。在线从 MySQL 检索到的价格,并存储在 varchar 中。

Chrome 的结果

FireFox 的结果

【问题讨论】:

    标签: javascript angularjs google-chrome firefox ionic-framework


    【解决方案1】:

    谷歌浏览器中一定有缓存,试试Empty Cache and Hard Reload选项,可以在开发者模式下执行,只需右键单击刷新按钮!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-07
      • 2015-10-25
      • 2011-07-18
      • 2017-03-31
      • 2021-07-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多