zoukankan      html  css  js  c++  java
  • Simple Shopping Cart By AngularJS

    <body ng-controller='CartController'>
        <h1>Your Order</h1>
        <div ng-repeat='item in items'>
            <span>{{item.title}}</span>
            <input ng-model='item.quantity'>
            <span>{{item.price | currency}}</span>
            <span>{{item.price * item.quantity | currency}}</span>
            <button ng-click="remove($index)">Remove</button>
        </div>
        <script src="~/Scripts/angular.js"></script>
        <script>
            function CartController($scope) {
                $scope.items = [
                { title: 'Paint pots', quantity: 8, price: 3.95 },
                { title: 'Polka dots', quantity: 17, price: 12.95 },
                { title: 'Pebbles', quantity: 5, price: 6.95 }
                ];
                $scope.remove = function (index) {
                    $scope.items.splice(index, 1);
                }
            }
        </script>
    </body>

    Use module:

    <body ng-controller='CartController'>
        <h1>Your Order</h1>
        <div ng-repeat='item in items'>
            <span>{{item.title}}</span>
            <input ng-model='item.quantity'>
            <span>{{item.price | currency}}</span>
            <span>{{item.price * item.quantity | currency}}</span>
            <button ng-click="remove($index)">Remove</button>
        </div>
        <script src="~/Scripts/angular.js"></script>
        <script>
            var myModule = angular.module('myApp', []);
            myModule.controller('CartController', function ($scope) {
                $scope.items = [
                { title: 'Paint pots', quantity: 8, price: 3.95 },
                { title: 'Polka dots', quantity: 17, price: 12.95 },
                { title: 'Pebbles', quantity: 5, price: 6.95 }
                ];
                $scope.remove = function (index) {
                    $scope.items.splice(index, 1);
                }
            });
        </script>
    </body>
  • 相关阅读:
    tnagios
    python-gearman使用
    yaml
    中国大陆互联网国际出口情况(2015年)
    vsftpd配置
    spoj-ASSIGN-bitDP
    spoj-ANARC05H -dp
    Light oj 1379 -- 最短路
    SPOJ-394-ACODE
    2018年东北农业大学春季校赛
  • 原文地址:https://www.cnblogs.com/pengpenghappy/p/3802666.html
Copyright © 2011-2022 走看看