javascript - Angularjs Select to Select data passing -
so having inexperienced issues angularjs select function. lol have vehicle program info of car. have 3 select options. make, model, , year. grabbing info json server. 'make' input shows car makes (every make object has model object). 'model' input shows models make user has chosen. dont know how grab data of make , show models make. (and year).
html
<label class="item item-input item-select"> <div class="input-label"> make </div> <select ng-model="make" ng-options="item.name item in items.makes"> </select> </label>
js
.controller('milesctrl', function($scope, vehicle, x2js, $http) { /////////my vehicle/////////// $scope.formdata = {}; vehicle.getcar().then(function(data){ console.log(data.data); $scope.items = data.data; }); });
please have @ example: http://jsfiddle.net/s7p0zavy/
suppose have $scope.items following:
$scope.items = [ { makes: [ {name: 'make01', models: [ {name:'model0101', years:['111','112']}, {name:'model0102', years:['121', '122']} ] }, {name: 'make02', models: [ {name:'model0201', years:['211','212']}, {name:'model0202', years:['221', '222']} ] } ] } ];
then can display information below:
<div class="input-label">make</div> <select ng-model="make" ng-options="item item.name item in items[0].makes"></select> <div class="input-label">model</div> <select ng-model="model" ng-options="item item.name item in make.models"></select> <div class="input-label">year</div> <select ng-model="year" ng-options="item item in model.years"> </select>
Comments
Post a Comment