Group By - This is the component of group list item or value added from the option label.
value.category group by value.name for (key, value) in data
The above format is write a (<optgroup>) select option UI
<optgroup label="mobile"><option value="0">Moto,MicroMax,HTC,Apple</option></optgroup>
HTML
<div ng-app="Opt">
<div ng-controller="OptCtrl">
<span>Name :</span>
<span>
<select ng-options="value.category group by value.name for (key, value) in data" ng-model="yourItem">
<option value="">-- Select Country --</option>
</select>
<br>
</div>
</div>
Angular Script
var app = angular.module('Opt',[]);
app.controller('OptCtrl', function($scope){
$scope.data = [
{"id":1, "name":"mobile","category":["Moto","MicroMax","HTC", "Apple"]},
{"id":2, "name":"Browser","category":["chrome","safari","opera", "mozilla"]},
{"id":3, "name":"fruits","category":["Mango","Apple","Orange", "Banana"]}];
$scope.yourItem= "";
});
Result
Demo
Comments
Post a Comment