FAQ Database Discussion Community


ngOption default selected option

angularjs,angular-ngmodel,angular-services,angularjs-ng-options
How to have a default option in select box...I tried several options and do not get it I tried creating a scope on my contralador with the value of the object that comes from json: Like this: $scope.productSelect = $scope.item[0]; this my code: html: <select id="variant" class="form-control variant-select" ng-model="productSelect" ng-options="product...

Getting Select box value in Angular - without using ng-options?

angularjs,angular-ngmodel
I'm trying to modify a form which is using a select box that is populate NOT using ng-options. The form itself is bound to an angular controller. Is there still a way for me to know the selected value of the select box even though the select values were not...

angularjs: custom directive to check if a username exists

angularjs,angularjs-directive,angular-ngmodel
I have my registration form with textbox username. I want to do is when the user enter the username, the custom directive will check if the entered username is exists in the database. directives.js angular.module('installApp').directive('pwCheck', function ($http) { return { require: 'ngModel', link: function (scope, elem, attrs, ctrl) { elem.on('blur',...

AngularJs - ng-model in a SELECT

javascript,jquery,angularjs,angular-ngmodel
JSfiddle Problem: I have a SELECT-element in my page, which is filled in with an ng-repeat. It also has a ng-model which has a default value. When I change the value, the ng-model adapts, that's ok. But the dropdown-list shows an empty slot at launch, where it should have the...

ngModel Changing to Child Scope

angularjs,angular-ngmodel
When I edit a value through an input field that is bound (perhaps bound isn't the right term) to a parent controller's scope, it seems to re-bind to the child controller's scope. This eliminates my ability to affect the value with functions built into the parent scope (clicking the button...

Specifying Angular ngModel Value with ng-repeated options

javascript,angularjs,angularjs-scope,angularjs-ng-repeat,angular-ngmodel
I've got a select dropdown, whose options are being ng-repeated out of an object called $scope.bars. However, my ng-model, which is set to a sub-value of $scope.bars, is not correctly choosing an option. Instead, the select box is blank by default, indicating an 'undefined' value. Here's my HTML: <div ng-app="programApp"...

AngularJS assign values to items in ng-repeat array using ng-model and retrieve those values

arrays,angularjs,angularjs-ng-repeat,angular-ngmodel
ok so this is turning out to be a little harder than expected. i have two arrays one for products and one for options. where the problem starts is when i try to give each product its own options array with its own scope, meaning when one option is selected...

Select not selecting when binding with ng-model and ng-options

javascript,angularjs,select,angular-ngmodel,ng-options
Here's my select: <select class="form-control" ng-options="assistanceType as assistanceType.name for assistanceType in assistanceTypes" ng-model="selectedRecord.assistanceType"></select> Here's what I'm using to load the Assistance Types: $scope.getAssistanceTypes = function () { $http.get('/api/assistanceType/getAll'). success(function (data, status, headers, config) { $scope.assistanceTypes = data; }). error(function (data, status, headers, config) { alert(data.ExceptionMessage); }); } Here's the result:...

Ng-model not working on dynamically added html controls

javascript,angularjs,angularjs-ng-repeat,angular-ngmodel
I am trying to preselect the selects with same ng-model but when I add an item in $scope.alertConditions.rows the selects are not pre-selected based on ng-model. Any help is appreciated. HTML: <div class="alert_center_table_body" ng-repeat="alertCondition in alertConditions.rows track by $index"> <div></div> <div> <select ng-model="alertConditions.run_alert" ng-change="getRunDates(alertConditions.run_alert, $index)"> <option ng-repeat="run_alert in runAlerts"...

Angular ng-model on input not binding within ng-repeat

angularjs,angularjs-ng-repeat,angular-ngmodel
I'm trying to get the input entry {{post.title}} to post upon submit, but only {{post.upvotes}} is posting. Can anyone see what I might not be seeing in my code? The result when I submit is - upvotes: 0 When I change {{post.title}} to {{title}}, it posts fine, but I can't...

Two inputs with one way binding in ng-model

javascript,angularjs,angularjs-directive,angularjs-scope,angular-ngmodel
I try to make an application which have two inputs text (say parent and child) , each one has ng-model . I want to make it one way binding , mean , change in the parent input should display the same value in the child , and change in the...

ng-model in select box is not working correctly

javascript,angularjs,angular-ngmodel
I am using angular js to draw select boxes. <select ng-model="selected"> <option value="{{obj.id}}" ng-repeat="obj in values">{{obj.name}} </option> </select> selected id - {{selected}} Here the default selected is not initialized according to value selected. Have made a fiddle for the problem....

Nested/embedded $resources in ngRepeats

angularjs,angularjs-ng-repeat,angular-ngmodel,angular-resource
My API populates some nested models. Using a shopping example, when you query orders, the items property is populated with the description and quantity instead of returning just the item IDs. orders: [ {_id: 1, items: [ {_id: 100, description: "apple", // from lookup in the Items table quantity: 4...

How to programmatically uncheck checkbox?

angularjs,checkbox,angular-ngmodel
I want to programmatically uncheck a checkbox. I know how to it in javascript but since I'm using angular, i think it's different. Here's the link of jsfiddle : https://jsfiddle.net/TKVH6/499/ This is the first time I used jsfiddle so please let me know if you cant see the script and...

Multiple instances of custom directive, confusion with ngModel

angularjs,angularjs-directive,angular-ngmodel
I've created a custom directive to render a slider for a question (essentially wrapping jquery ui slider). The directive takes an ngModel and updates it when the user uses the slider, and there's a $watch attached to the parent model (the ngModel passed to the directive is only a part...

Not getting the updated value of ng-model when ng-model is changed programaticaly

angularjs,angular-ngmodel
When I check master check-box all the children check-box should be checked and their content should also be shown when check-box is checked otherwise their content should not be shown but the issue is that child check-boxes are checked but their content is not shown when I check master check-box...

Having trouble using ngChange to update model

javascript,angularjs,angular-ngmodel,angularjs-ng-change,ng-controller
I just started learning the basics of Angular. I'm attempting to making an annual salary converter, just for fun. I'm having difficulty with my monthly ng-model updating when the yearly model is changed by the user. The fields are input tags. Here is the code <!doctype html> <html ng-app="salaryApp"> <head>...

Change selected