angularjs - Get other values from select -


i have array values service:

serv.success(function (data) {     $.each(data.records, function(i, product) {         saleitem.push({             value: product.id,             text:  product.name,             price: product.price         });     }); }); 

and want grab price value when select specific option:

<select ng-model="product.id" ng-options="s.value s.text s in saleitem">     <option style="display:none" value="">selecione um produto</option> </select> 

try using this

<body ng-app="myapp" data-ng-controller="homectrl">    <select ng-model="product.id" ng-options="s.price s.text s in saleitem">     <option style="display:none" value="">selecione um produto</option> </select>  <p>price {{product.id}}</p>  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script> <script>  angular.module('myapp', []);  angular.module('myapp').controller('homectrl', ['$scope', function($scope) {   $scope.saleitem =  [                           {                               "value":1,                               "text":"p1",                               "price":100                           },                            {                               "value":2,                               "text":"p2",                               "price":200                           }                 ]           }]);  </script> </body> 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -