FAQ Database Discussion Community


ngModelCtrl - $setViewValue without $setDirty();

javascript,angularjs,angularjs-directive,angular-ngmodel
I have a directive which manipulates the $viewValue of an input field via ngModelCtrl.$setViewValue() on blur. function _onFocus () { presentation = false; if(!ctrl.$isEmpty(ctrl.$modelValue)) { ctrl.$setViewValue(String(ctrl.$modelValue).replace(/\./, ',')); ctrl.$render(); } } Plunkr Since this is only an appearance thing, I wonder if there is the possibility of setting the ViewValue without...

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

How to populate table with json data using angular?

javascript,json,angularjs,angular-ngmodel
I have loaded the json data successfully via http but having a problem populating a table with this json data based on the entered value 'name'. Plunker Below. Plunker json [ { "name": "Tim", "address": "Road", "phone": "1234", "status": "busy" }, { "name": "Sue", "address": "Street", "phone": "4321", "status": "available"...

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

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

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

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

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

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

ng-options filter by value in another dropdown

angularjs,angular-ngmodel,ng-options
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...

How do I bind the same data to different options using angulajs?

angularjs,ionic-framework,ionic,angular-ngmodel
I'm trying to select data and bind it to a specific item, however once I select the data, all of my items are now bound to the selected data. How can I select specific data to each of my items. here is my demo. http://play.ionic.io/app/cb25b106e671...

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

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

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

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

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

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

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

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

ng-model issue on logic

javascript,angularjs,angular-ngmodel
I have a little issue with an ng-model I am working on. First I will show the part where the ng-model is working properly <input type="text" ng-model="slip.risk" ng-change="riskWinCalculations(slip, 'RISKSTRAIGHT')"> <input type="text" ng-model="slip.win" ng-change="riskWinCalculations(slip, 'WINSTRAIGHT')"> <strong>To Win: </strong>{{straightTotalWin | currency}} <strong>Total Stake: </strong>{{straightTotalStake | currency}} now the html where the ng-model...

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

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

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

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

Angular query on mobile

javascript,angularjs,angular-ngmodel
Simply I am using ng-model="query" on my project as a search. It works great but for some reason it won't work on mobile (specifically iphone 5s). Is there any reason for this? I have tried searching for answers on google and haven't come up with anything.

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

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

AngularJS $scope values from ng-model lost from page to page in same controller - Ionic Framework

angularjs,angularjs-scope,ionic-framework,ionic,angular-ngmodel
I have this page which links the input.countNum scope variable to the input with ng-model. The value which is displayed on the button shows fine. When you click the button on the first page, it navigates to the second page which also displays the scope variable. But the variable is...

Can't change select option item angular

javascript,json,angularjs,html-select,angular-ngmodel
I have a select option like this: <select ng-init="filterSelected = getItems.data.key" ng-model="filterSelected" ng-options="data.key as data.label for data in getItems.data" ></select> In which i parse a json that returns me some results that shows as item in this select. This is not a problem, i can display the items but i...

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

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

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

AngularJS - Directive ngModel doesn't get updated

angularjs,angularjs-directive,angular-ngmodel
I have a good understanding of AngularJS Directives, but I'm thinking I'm missing something here with my directives. What's wrong : On the initial page load, the ngModel gets triggered correctly and I successfully receive the data and it's modeled in the input. Everything I do after... doesn't work. If...

Angular Js ng-model not updating variable in an inner function

angularjs,angular-ngmodel
I have the following code in my controller: appControllers.controller('myCtrl', [ '$scope', function($scope) { $scope.timeFreeze = false; $scope.ws = new WebSocket("ws://localhost:8080/ws"); $scope.ws.onopen = function() { $scope.ws.send('{...}'); }; $scope.ws.onmessage = function (evt) { var received_msg = JSON.parse(evt.data); //...do something with the data... console.log($scope.timeFreeze); // This is ALWAYS false!!! Why? if ( $scope.timeFreeze...

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

ng-model and value combination not working for input text box

javascript,angularjs,input,angular-ngmodel
I'm having two input text box. I need to combine the values entered in two text boxes and display it in the third. I'm able to display it if I use only the value in the third text box. Box 1: <input type="text" ng-model="entity.name"> Box 2: <input type="text" ng-model="entity.code"> Box...

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

Change selected