【发布时间】:2018-10-12 19:41:19
【问题描述】:
我希望在单击“添加到购物车”按钮时,项目将添加到“我的购物车”中。这是我的 angularJS 代码
app.controller("OnlineShopping", function($scope)
{
$scope.items = [
{Product:"Moto G2", Desc: "Android Phone", Price: 10999},
{Product:"The Monk who sold his ferrari", Desc: "Motivational book", Price: 250},
{Product:"Mi Power Bank", Desc: "Power Bank", Price: 999},
{Product:"Dell Inspiron 3537", Desc: "Laptop", Price: 45600}
];
$scope.editing = false;
$scope.addItem = function(item) {
$scope.items.push(item);
$scope.item = {};
};
我在这里发现了一些使用 ng-model 和 ng-bing 的问题,但它适用于文本框,但这里我没有从文本框中获取输入。这是我的“我的购物车”的不完整代码
<h2>My Cart</h2>
<div style="border: 1px solid blue;">
</div>
<table border="1" class="mytable">
<tr>
<td>Item</td>
<td>Description</td>
<td>Price</td>
</tr>
<tr ng-repeat="item in items">
<!-- What should be here -->
</tr>
</table>
【问题讨论】:
-
您是否希望我们完成您的代码..或者您有一些疑问?
-
@pankajparkar 我只是想知道我哪里出错了。检查卡西尔的答案
-
我期待您更新您的问题..bdw 很高兴看到您的问题得到解决
标签: javascript jquery html angularjs