如何更新mvc中layout.cshtml中的ng-model值

时间:2015-06-01 18:22:25

标签: asp.net-mvc angularjs

我在asp.net mvc中使用angularjs.I创建一个电子商务网站。我在我的应用程序中添加了布局页面,其中包含相同的页眉和页脚以供完整的应用程序使用 这是我在线网站的链接 www.stylesstore.com

现在我必须在我的应用程序中计算购物车价值。我在将项目添加到购物车并尝试更新项目计数模型时计算项目。但它没有更新标题中的值。但是当我在我的cshtml页面中添加相同的模型时,它会更新模型

这是我用来计算项目的代码

$scope.addToCart = function (Picture1, ProductName, UnitPrice) {
    var count = 0;
    var item = new cartItem(Picture1, ProductName, UnitPrice);
    $scope.items.push(item);
    store.set('StyleStoreCart', $scope.items);
    sharedService.addProduct($scope.items);
    console.log("storegetitems", $scope.getCookies);
    //$scope.Itemcount = $scope.items.length;
    console.log($scope.Itemcount);
    // store.set('itemcount', $scope.Itemcount);
    toastr.options = {
        "closeButton": false,
        "debug": false,
        "newestOnTop": false,
        "progressBar": false,
        "positionClass": "toast-bottom-right",
        "preventDuplicates": false,
        "onclick": null,
        "showDuration": "300",
        "hideDuration": "1000",
        "timeOut": "5000",
        "extendedTimeOut": "1000",
        "showEasing": "swing",
        "hideEasing": "linear",
        "showMethod": "fadeIn",
        "hideMethod": "fadeOut"
    }
    toastr.warning('Item Added to Your Cart', 'Cart Update')
}

在我的布局页面中我使用了这个

<div class="header-right" ng-controller="products">
    <ul>
        <li class="phone">+91 99 79 62 1376</li>
        <li class="mail"><a href="mailto:gurpreet.bawa7@gmail.com"> gurpreet.bawa7@gmail.com</a></li>
        <li class="checkout">
            <a href="javascript:void(0)" ng-click="goToCart()">
                <span class="cart">
                    ({{items.length}})
                </span>
                <span class="check">Checkout</span>
            </a>
            @*<div class="shopping">
                <h5>Your Shopping Cart is empty.</h5>
                <p>Give it purpose—fill it with books, movies, mobiles, cameras, toys and fashion jewellery.</p>
            </div>*@
        </li>
    </ul>
</div>

任何人都可以告诉我如何更新此标头值? 感谢

0 个答案:

没有答案