Category: ng-options

Highlight selected value in drop down in angularjs

I would like to display the selected value in the drop down in angularjs. <!DOCTYPE html> <html> <script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js”> </script> <body> <div><select class=”form-control” size=”30″ style=” height:100px;width:100px” ng-model=”value” ng-options=”c.name for c in customers track by c.id”> <option value=”” selected hidden /> </select></div> </body> </html> By doing the above way it doesn’t highlight the selected value.If I change the ng-options as ng-options=”c.id as c.name for c in customers track by c.id”. In the value I see id […]

Why the below piece of code is not working for me in angularjs

The below code is to populate a drop down select option with json data provided. BUt it is not populating. this is not populating a dropdrop with json data in the fucntion <select ng-model=”selectedName” ng-options=”x for x in values.names”> </select> <select ng-model=”places” ng-options=”x for x in values.places”></select> </div> <script> var app = angular.module(‘myApp’, []); app.controller(‘myCtrl’, function($scope) {$scope.values ={ names :[“Emil”, “Tobias”, “Linus”] places :[“hyd”,”tnd”,”sec”] } }); </script> <p>This example shows how to fill a […]

AngularJS Select Default Option from Select when user input changes

This question is specific to AngularJS 1.6.5 and above and does not apply to any previous versions. I have a form with some ng-options selects and some text inputs. When a user selects the None / Custom option, a text input appears to the right. Once the user starts typing in that input, the None / Custom option is deselected and a new unknown option is added. This is the result of a bug fix […]

Reseting ng-option to default value from the Controller in AngularJS

I have the following select in my app: <select ng-model=”diagnose” ng-options=”c as c.Name for c in diseases | orderBy:[‘Name’]”> <option value=””>Diagnose*</option> </select> Once I send the data to the server, I reset the whole form, but the select goes to empty option instead of showing the empty value/hardcoded option. I’ve tried with the following options: $promisedb.then(function (data) {$scope.diagnose = [1]; }); And: $promisedb.then(function (data) {$scope.diagnose = [0]; }); And: $promisedb.then(function (data) {$scope.diagnose […]

AngularJS select option text

I have a form for updating my pages. A Page has its parent page and I want to have a combobox where I can choose another parent page for my current Page. When the page is loaded I don’t see the title of the current page’s parent in the combobox. When I open the combobox I can see all the titles of all the pages. Page.java public class Page { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name […]