FAQ Database Discussion Community


AngularJS adding incremental numbers to a select list

javascript,angularjs,angular-ngmodel,ng-options
I want a select box where I can choose from a list with a min/max number. Currently my number is just 1 to 10 so I have the below. <body ng-app="demoApp"> <div ng-controller="DemoController"> <select ng-model="selectedItem" ng-options="opt as opt for opt in options"> </select> The value selected is {{ selectedItem }}....

Parsing data to ng-model not working

angularjs,angularjs-ng-repeat,angular-ngmodel
I'm trying to parse data to ng-model, but I'm getting an error. html: <div class="process-checkbox-holder" ng-repeat="time in data"> <div class="checkbox-title">{{ time.id }}</div> <div class="process-checkbox"> <input type="checkbox" ng-model="{{ time.model}}" value="None" id="process-checkbox" name="check"> <label for="process-checkbox"></label> </div> </div> data: $scope.data = [ {"id":"00", "model": "user.hourzero"}, {"id":"01", "model": "user.hourone"}, {"id":"03", "model":...

Angular JS ng-model not initiating properly for the first time

javascript,angularjs,angular-ngmodel
I am using Angular JS ng-model to track the selected value of the select tag. here's the example http://jsfiddle.net/8853oxb1/3/ function ControllerA($scope) { $scope.optionsArray = [1,2,3,4,5]; $scope.optionsObject = {"India" : "IN" , "Singapore" : "SG", "Malaysia" : "MY", "Indonesia" : "INDY"}; } If, I go to a dropdown by using a...

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',...

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"...

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 forms ng-repeat - posting back the current $scope only, not whole object

angularjs,angularjs-scope,angularjs-ng-repeat,angular-ngmodel
I have multiple forms using ng-repeat. <div ng-repeat="individual in orderDetails track by $index"> <form ng-submit="saveDetails();"> <input ng-model="individual.order.statusText"> <button type="submit">Save changes</button> </form> </div> Here's an example of what's stored in my object, for each individual (IE - object) in OrderDetails. orderDetails { object{ foo {}, bar {}, order {} }, object{...

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 throwing error on input type number in angular 1.3

javascript,angularjs,html5,angular-ngmodel
I have an input field which I want he user to input a number, so I have made an input field with type="number". When I use it in 1.2 I get no errors <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js"></script> <script> var app = angular.module('app', []); app.controller('MainCtrl', ['$scope', function ($scope) { $scope.person = [ {"name":...

AngularJS update ng-model if value = true

javascript,angularjs,angular-ngmodel
Hello I'm building an app that overviews data from a database. I have a form which loads that information with ng-model into input fields, The user have the option to change these values. However I dont want the values on the overview to live update when the user changes the...

Updating a value based on a range of inputs in AngularJS

javascript,angularjs,angularjs-ng-repeat,angular-ngmodel
What I am essentially trying to achieve here is to have a remaining amount that decreases in amount as the user enters the amount in to a series of text fields. These text fields are generated by an angular loop and its the remainingAmount var that I need to be...

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...

Do I need 2 ng-models for this?

javascript,angularjs,angular-ngmodel
I'm trying to create a form where the input fields are populated with values from an array, but the form is saved into a different array. For example the fields would be populated from this array { "organisation": [ { "OrgID": 1234, "OrgName": "Organisation one" }, { "OrgID": 4567, "OrgName":...

How dynamically add new input element if all others was filled in AngularJS

javascript,angularjs,angularjs-directive,angularjs-scope,angular-ngmodel
please watch this Plunker So I working with angular and need to add new input field when all others are filled in (by default on page placed 5 inputs and if all of them are filled automatically add one more input if new input also using will add one more...

How to track behavior of ngModel array item using .directive

javascript,angularjs,directive,watch,angular-ngmodel
Hi everyone I'm use angularjs not so long time ago and now I have one issue related with this framework that i can't to solve. So the problem in next: I have few input fields that generate via ng-repeat: <div class="form-group" ng-repeat="(i, name) in name_list track by $index"> <div class="row">...

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...

pass the ng-model value to angular directive

javascript,angularjs,angularjs-directive,angular-ngmodel
I have a scenario where I have certain number of text-boxes and when I click on any of the text-box, its corresponding ng-model is to be printed on the browser console. I have written the following angular code: <html ng-app="myApp"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0-beta.0/angular.min.js"></script> <script> var app = angular.module("myApp", []) app.controller("myAppCtrl",...

Angular js unbind and bind dynamically not working

angularjs,angular-ngmodel,ng-bind
I have an 2 inputs with ng-model and two elements binding the two models, I want that when I click on a button it switch the bindings i a way that element 1 binds model 2 and element 2 bind model 1, it work perfectly, but when start changing models...

AngularJS Show List Items based on ng-model

angularjs,angular-ngmodel
I'm trying to create some functionality where the user would have an input box and all the data (li's) below are hidden. Then when a user types into the input box, those li's that match that text are show. What would the best way to do this using angular? I've...

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...

angularjs update model based on sum of other fields

javascript,angularjs,angular-ngmodel
I want to be able to update a value in my data model based on the result of two other fields. using <td><input ng-value="s.hours*s.rate"></td> I have no problem calculating the result but how am I able to bind it to toal? eg I tried <td><input ng-model="s.total" ng-value="s.hours*s.rate"></td> but the model...

Change selected