ng-options

ng-options filter by value in another dropdown

只谈情不闲聊 提交于 2019-12-31 02:18:10
问题 This seems to be a really straight forward code, but I cannot figure out why it is not working. I want to filter the 'model' dropdown by selected 'make', Make: <select ng-model="makeng" ng-options="option.display for option in makes"> <option ng-disabled="true" ng-selected="true" value="">Select a make</option> </select> Model: <select ng-model="modelng" ng-options="option.display for option in models | filter:{make:makeng}"> <option ng-disabled="true" ng-selected="true" value="">Select a

Angularjs: ng-options: How to order options with group and non-group

折月煮酒 提交于 2019-12-30 22:51:29
问题 I have my group by ng-options looks like this <select ng-model="selected" ng-options="d.title group by d.group for d in data"></select> Here is my data $scope.data = [ { group:"", title:"No GroupA" }, { group:"Group_1", title:"1" }, { group:"", title:"No GroupB" }, { group:"Group_2", title:"2" }, { group:"", title:"No GroupC" } ]; the problem is that this creates the optgroup on the bottoms of this select menu, not the order as same as my data list. No GroupA No GroupB No GroupC [Group_1] 1

How to remove initial blank option and select <option> value when using ng-repeat or ng-options?

最后都变了- 提交于 2019-12-30 14:50:08
问题 Angular newbie. Filtering json data returned via dataservice, and filter is done via dropdown. What i would like to do is a combination of things: I would like to remove the initial blank value returned via Angular; I would also like to have it pre-select a value by default that is not included in my data object (in my case, returning all objects, added as a select option via my html); and I would like to have that initial default value displayed when the page is rendered. I can remove the

ng-options loop through an array of objects within an object?

ぃ、小莉子 提交于 2019-12-25 05:23:44
问题 I have this object format { first_name : "Bob", last_name : "Smith", addresses : [ {address:"1 Baker Street", city: "london" }, {address:"2 Baker Street", city: "london" } ] } I want to set the address bits in the select dropdown i.e. "1 Baker Street", "2 Baker Street", This is my code <!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <body> <div ng-app="myApp" ng-controller="myCtrl"> <select ng-model="selectedAddress" ng

ng-options with a dynamic expression is not working

不问归期 提交于 2019-12-25 04:44:42
问题 I'm trying to create a directive in angular, to replace the regular dropdown. I need to be able to set a dynamic expression to ng-options but doesn't seem to be working inside the directive. It works perfectly outside it. This is the directive angular.module('app.dropdown',[]) .directive('swDropdown',[ function ( ){ return { restrict: 'E', replace: true, template:'<div><select ng-model="swModel" ng-options="{{expression}}" ></div>', link: link, scope:{ swOptions:"=", swLabel:'@', swValue:'@',

AngularJS set default selected option in dropdown

一笑奈何 提交于 2019-12-25 04:27:30
问题 I am relatively new to AngularJS. Learning every bit of it. I have been worked on KnockoutJS for couple of years and find it comfortable to work on JavaScript. I am working on a simple Task Manager app which has following JSON as a result on API call for individual task. { "Id": 1, "title": "Culpa nisi irure qui consectetur non reprehenderit incididunt mollit voluptate culpa enim.", "description" : "test description", "owner": "Hunter Mcdonald", "priority": 1, "isActive": false, "picture":

ng-options is hiding the blank value with AngularJS V1.5 [duplicate]

回眸只為那壹抹淺笑 提交于 2019-12-25 00:50:10
问题 This question already has answers here : how to bind default value to select using ng-model using AngularJS V1.6 (3 answers) Closed last year . I followed the instructions specified in the V1.3 documentation to have a default option in one of my selects. Therefore in my Angular ̶1̶.̶3̶.̶1̶5̶ 1.5.7 template I have: <div class="form-group"> <div class="col-md-12"> <select ng-model="selectedObj" class="form-control" ng-options="obj.id as obj.name for obj in objects"> <option value="">All objects

ng-options (key, values) in object [duplicate]

99封情书 提交于 2019-12-24 22:41:22
问题 This question already has answers here : key-value pairs in ng-options (3 answers) Closed last year . I want to know how to use ng-options render a select Element works. var data = { china:[ {name:'shanghai',code:1}, {name:'zhejiang',code:2} ], us:[ {name:'Alabama',code:3}, {name:'Alaska',code:4} ] }; than,will render like this <select> <optgroup label="china"> <option value="1">shanghai</option> <option value="2">zhejiang</option> </optgroup> <optgroup label="us"> <option value="3">Alabama<

Ng-Options in Angular for Arrays and Objects

落花浮王杯 提交于 2019-12-24 21:30:12
问题 First of all 2 working solutions: Example 1 - Array in Controller $scope.s1 = [ { "name": "Item1", "id": 1 }, { "name": "Item2", "id": 2 } ]; View 1 <select ng-model="select1" ng-options="foo.id as foo.name for foo in s1"> <option value="">Select a Value</option> </select> Example 2 - Object in Controller The same concept may help you also here, if you know the name of "myS2": $scope.s2 = { "myS2": [ { "name" : "Item1", "id" : 1 }, { "name": "Item2", "id": 2 } ] }; View 2 <select ng-model=

how to set default value after ng-options completed?

风格不统一 提交于 2019-12-24 07:49:54
问题 assume that this is my controller: function MainController(BaseInformation, baseInformationConstants) { var vm = this; getGenders(); function getGenders() { vm.genders = BaseInformation.list({headerId: baseInformationConstants.genderId}); } } and this select tag, that i want to set default value for it with ng-init , but it didn't worked: <select ng-init="vm.user.genderId = {id: vm.genders[0].id}" ng-model="vm.user.genderId" ng-options="gender.id as gender.topic for gender in vm.genders track