angularjs - why we need to make pair in ng-option is select for Angular .? though we can make are work done witho -
hi can 1 tell me why need make "(k, v)" in
ng-options="k v (k, v) in types" can work done writing ng-options="k v v in types" also.
<div ng-app="myapp" ng-controller="myctrl"> <p>select car:</p> <select ng-model="selectedcar" ng-options="y.brand (x, y) in cars"> </select> <h1>you selected: {{selectedcar.brand}}</h1> <h2>model: {{selectedcar.model}}</h2> <h3>color: {{selectedcar.color}}</h3> <p>the visible text inside dropdown list can property of value object.</p> </div> <script> var app = angular.module('myapp', []); app.controller('myctrl', function($scope) { $scope.cars = { car01 : {brand : "ford", model : "mustang", color : "red"}, car02 : {brand : "fiat", model : "500", color : "white"}, car03 : {brand : "volvo", model : "xc90", color : "black"} } });
examples
ng-options="single.value single.caption single in $ctrl.example.singles" ng-repeat="(indexsingle, single) in ($ctrl.example.singles | filter:{isvisible:true})" ng-repeat="single in $ctrl.example.singles" you curious middle 1 here in example :
<div ng-repeat="(indexsingle, single) in ($ctrl.example.singles | filter:{isvisible:true})"> index = {{indexsingle}} <div>
Comments
Post a Comment