javascript - How do I make a list in AngularJS? -


i want make products list products name , add products price & pv , bv.

here saved json data in $scope :

$scope.products = [  {"id":1,"name":'sp0300370 nutrient super calcium powder',"price":21,"pv":18,"bv":18},  {"id":2,"name":'sp0300315 calcium powser metabolic factors',"price":25,"pv":21,"bv":21},  {"id":3,"name":'sp0300372 super calcium powder children',"price":26.5,"pv":23,"bv": 23}]; 

angular binded html :

<div ng-controller="formcontroller">     <div class="form-group">       <label class="control-label col-sm-2">products</label>         <input auto-complete ui-items="products" ng-model="product">       <button type="button" ng-click="productlist()" class="btn btn-success col-sm-offset-10 col-sm-2">add product</button>     </div> 

this form through want make products selectable. thank

 <div ng-repeat="p in products" ng-click="p.selected=!p.selected" ng-class="{'selected-product':p.selected}">        <input type="text" ng-model="p.name" ng-value="p.name">        <input type="text" ng-model="p.price" ng-value="p.price">        <input type="text" ng-model="p.pv" ng-value="p.pv">  </div> 

is show array in angularjs , can edit. , following normal push operation add product list.

var newobject = {name : "a", price: 4, pv: 2323, selected: false} $scope.products.push(newobject) 

if want deeper operations , if have not experience, can propose use grid framework ui-grid

you see here working plunker


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -