追加HTML内部元素表中,这是我的HTML采用了棱角分明的js
<body>
<div ng-app="tham" ng-controller="tham-control">
<div class="container">
<table class="table table-bordered table-striped">
<thead>
<tr>`enter code here`
<th>Sl.No</th>
<th>Product</th>
<th>Cost</th>
<th>Quantity</th>
<th>Total</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr class="items">
<td><input type="number" ng-model="slno"/></td>
<td><input type="number" ng-model="product"/></td>
<td><input type="number" ng-model="cost"/></td>
<td><input type="number" ng-model="quantity"/></td>
<td><input type="number" ng-model="total" value="{{ cost*quantity }}"/></td>
<td><button ng-click="add_row()" >Add</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
这是我的角的js和jQuery
<script type="text/javascript" src="js/jquery-1.11.3.min.js" ></script>
<script type="text/javascript" src="js/angular.min.js" ></script>
<script>
// filter can be added using pipe charcter
var app = angular.module("tham",[]);
app.controller("tham-control",function($scope){
$scope.cost = 0;
$scope.quantity = 0;
$scope.total = 0;
$scope.add_row = function(){
$this = $(this);
var html = $this.parents('tr.items').html();
var new_html = "<tr class='items'>"+html+"</tr>";
$this.parents('tbody').append(new_html);
}
});
</script>
这里我想要做的是,当我点击“添加“按钮然后我想添加”tr.items“行到”tbody“标签使用Angular Js。有人请纠正这个问题,如果不是。
非常感谢@pbaris。这正是我想要的。但我没有得到这个逻辑。我知道jQuery和JavaScript,但我是一个成角度的begginer。所以你可以请建议我一个很好的文档来学习所有这些东西。 – Thameem
http://www.tutorialspoint.com/angularjs和https://thinkster.io/a-better-way-to-learn-angularjs这是一个好开始 – pbaris
谢谢@pbaris .... – Thameem