Search Posts

Category: ng-options

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 […]

Filter results in table using select created through object property in angularJS

I’m trying to create a filter which will filter out the results in the table based on the value selected in the dropdown. Currently, it works for all the dropdowns except the ‘type’. The ‘type’ dropdown has been created using the unique properties from an array of objects. So, now, it contains two values ‘Internal’ and ‘External’. Based on the value I select, it should show me only the filtered results in the table. But […]

Angular : Can ng-options (bound to ng-model ( db table) ) allow input and/or edit of an option, if so how please

I’m hoping angularjs ng-options can allow a user to enter a new value / option or edit an existing one in-situ Is this possible? or is there a way to do so? My code: <div class=”col-md-2″> <select class=”form-control” ng-model=”BatchNos.Selected” ng-options=”item.BatchNo for item in BatchNos track by item.BatchId” style=”background-color:dimgray;font-weight:Bold;color:white”> </select> </div> Source: AngularJS

Keeping Angularjs HTML Green

When I add ng-options to a select element, I get options that look like this: <select name=”folderId” data-ng-model=”message.folderId” data-ng-options=”folder.id as folder.name for folder in folders”> <option value=”” class=””>No Folder</option> <option label=”Bulk” value=”string:0fedcc77-4cc5-4a9a-ba2f-847f8581d4d7″ selected=”selected”>Bulk</option> <option label=”Auto Responder” value=”string:d0898116-88ce-4e25-8d91-b17a7a29adc1″>Auto Responder</option> <option label=”Customer Service” value=”string:6ec044c1-c378-42de-82ad-f3dc63c58f00″>Customer Service</option> </select> The problem with the above is that Angular is adding string: in front of the folder ID. This form is submitting data to a remote page when clicked. However, the string: […]

Angular adding <option value="?string:abc ?"></option>

When i try to change unusedEmailArray on select of dropdown options, Angular add <option value=”? string:work?”></option> in the HTML. <div ng-repeat=”email in emails” > <div> <select type=”text” id=”emailType” name=”email_type_{{$index}}” placeholder=”Type” ng-model=”email.email_type” ng-model-options=”{updateOn:’default blur’}” ng-change=”showChangesMade(email_type_{{$index}})” > <option value=”{{email.email_type}}” ng-selected=”email.email_type.length>0″>{{email.email_type}}</option> <option ng-repeat=”unusedArr in unusedEmailArray” value=”{{unusedArr}}”> {{unusedArr}} </option> </select> </div> Source: AngularJS

How to bind selected option value in ng-options to a value of object in the controller?

I have some troubles while trying to update the current selected value of an option in ng-options.I have an array which contains one object. The object has ‘value’ and ‘name’ properties whose values are constant. I am using this constant array in a custom directive with select and ng-options. This is part of the directive’s html: <select name=”{{vm.name}}” ng-model=”vm.model” ng-options=”arrayObject.value as arrayObject.name for arrayObject in vm.constantArrayofObject”> </select> And I use this directive in a form […]