FAQ Database Discussion Community


Angular JS two-way-binding doesn't work

javascript,angularjs,html5,angularjs-ng-repeat,angularjs-ng-model
I am not able to use two-way-binding in my controller. There is something strange but I don't understand it. My data structure is a javascript object containing an array of strings. $scope.schedule = { schedule_name: "Test 123", schedule_id: 1234, dates: [{ date: "2015-01-01" }, { date: "2015-02-01" }, {...}] }...

AngularJS - directive with a dynamic array of objects in form

angularjs,directive,ng-repeat,angularjs-ng-model
I'm trying to create a form that has a dynamic set of input boxes. I'm trying to get ng-models to work with array items and I am clearly doing something wrong. My problem seems to be indexing the scope array lineItems in the template. Here is my jsfiddle: http://jsfiddle.net/dk253/9ykuuobq/ Here...

Getting values of multiple select inside one ng-repeat

angularjs,angularjs-ng-repeat,angularjs-ng-model
I have a dropdown in one of my div, from which I am selecting the number of dropdowns to be in second div. My task is to be able to select the different values from each of the dropdowns inside the second div. Here is the code I am trying...

issue in using model expression in ng-if

angularjs,angularjs-directive,angularjs-scope,angularjs-ng-model
I am using ng.deviceDetector for my browser version detection and thus use it in ng-if to skip one of the span tags but some how it is not working. In my controller $scope.browserIdentity is resulting 'ie9.0' but when I use it in ng-if to check it, the condition is not...

How to do ng-bind logic check?

javascript,angularjs,angularjs-ng-repeat,angularjs-ng-model
I have some tweets data coming in, sometimes the database returns a different JSON object depending on the server (local, production etc). Sometimes the tweet content is in tweets[i].text and sometimes it's in tweets[i].highlights.text My current markup: <section ng-repeat="t in tweets"> <div ng-bind-html="t.text">{{t.text}}</div> <!-- <div ng-bind-html="t.highlights.text">{{t.highlights.text}}</div> --> Is there a...

Angularjs - using ng-repeat and ng-model to populate an array

javascript,arrays,angularjs,angularjs-ng-repeat,angularjs-ng-model
I'm trying to use ng-repeat and ng-model in order to populate an array. The number of required elements in the array comes from a select element`. The relevant part of my controller: app.controller('AddMsgCtrl', function($scope){ $scope.range = function(n){ var array = []; for(var i = 0 ; i < n ;...

AngularJS Adding additional Values to Option Select

angularjs,ionic-framework,angularjs-ng-model
I'm currently developing an AngularJS application. What I'm trying to achieve: I want the user to be able to select an address from the select dropdown and for this data to be passed to the next stage. Current Problems: I need to limit the amount of data show per address...

Angularjs dynamic ng-model names in ng-repeat and display input fields sum

angularjs,angularjs-ng-repeat,angularjs-ng-model
I have some simple data from which I'd like to create dynamic ng-model names from. I know that if you have those names handy you concatenate their input values together and display them, like so: <p>{{blah--bleh}}</p> But what if I don't know those ng-model names in advance, or how many...

Variables in ng-model in AngularJS

javascript,angularjs,angularjs-ng-repeat,angularjs-ng-model
I have a loop ng-repeat <div ng-repeat="data in datas"> Name: {{data.name}} <input type="text" ng-model="age"> </div> I want $scope.age become to $scope.age_data.name. Eg: $scope.age_Tan, $scope.age_Jim... So i have tried ng-model="age_{{data.name}}" but it make error. How to solve this?...

Sync two textboxes with different models

javascript,html,angularjs,angularjs-ng-model
I have a simple angular app with two textboxes with different models First Email: <input ng-model="firstEmail"/> Second Email: <input ng-model="secondEmail"/> Now, if something is typed in first email, I want it to get populated in second email but if second email is manually edited, then this binding should stop i.e....

How to reset custom input directive and its parent form to $pristine

angularjs,angularjs-directive,angularjs-ng-model,angularjs-ng-form
I've implemented a custom input directive - counter with a reset capability. The directive has require: "ngModel". I am resetting the pristine state of the directive's ngModel with $setPristine(). Unlike $setDirty(), $setPristine() does not touch the $pristine state of the parent form. Q: How do I "notify" the parent form...

Multiple ng-model from one ng

angularjs,angularjs-ng-model
Dear all I am creating a checkbox where it will show the name of multiple item with its price, user can choose what he/she wants. In ng-model I need both the name of the item and the price. Here is one sample code I found. <div class="checkbox" ng-repeat="item in items">...

AngularJS: Unable to format null or undefined value with ngModelController $formatters

javascript,angularjs,angularjs-directive,angularjs-ng-model
I have an AngularJS directive which contains a text input which has it's own model that gets passed a value from the controller scope through the directive's ng-model. Check out this pen (& code below): http://codepen.io/ericwshea/pen/KwXRyr The problem is that sometimes that model happens to be a null or undefined...

Preventing default on a checkbox doesn't prevent ng-model changing

angularjs,checkbox,angularjs-ng-model
Due to some animations, a visual glitch occurs if users toggle the state of a a checkbox too quickly. To prevent this happening, I wanted to limit the frequency with which the state could be changed. I thought a neat way to do this would be a directive. I've successfully...

angularjs ngModel not selecting option in select input

angularjs,angularjs-ng-model,angularjs-ng-options
Does ngModel working differently for input type text and select? The select control is not selected to reflect the initial model value. When I change the value of the select, input and currentUser.field change also, but if I change the value of input text to another key nothing happens to...

binding radio buttons to ng-model with angular in ng-repeat

javascript,angularjs,angularjs-ng-repeat,angularjs-ng-model
I'm currently learning angular.js and I'm running into a problem. I'm listing radio buttons based on the items fetched from the database and when I click on any of them my model doesn't get updated. I added an input to test and the input update the model right away. Any...

angularjs -date input with ng-model in miliseconds

angularjs,date,input,angularjs-ng-model
I have a number which represents the time in miliseconds since 1970 eg. 1388664300000 with: {{ day.date | date: "dd.MM.yyyy" }} it will render 07.05.2015 ! So far so good. Now I like to insert the same data into my input field: <input type="date" ng-model="day.DUTY"> to let the user adjust...

How to change a value in all items in an ng-repeat

javascript,angularjs,angularjs-ng-repeat,angularjs-ng-model
I have a data model that comes in, by default I give the first ticker a selected status of true. Now when a user clicks another item, I need to efficiently deselect all the others and set the selected value to true for the item clicked: <li class="ticker-li" ng-repeat="ticker in...

angularjs - not able to invalidate input (Object doesn't support property or method '$setValidity')

javascript,angularjs,forms,angularjs-ng-model,angularjs-validation
I try to do the following if ($scope.RetypePassword != $scope.resource.Password) { $scope.resource.Password.$setValidity("missmatch", false); } else { $scope.resource.Password.$setValidity("missmatch", true); } but fail with this error TypeError: Object doesn't support property or method '$setValidity' What can the reason be? resource.Password is databound to an input like this <input type="password" ng-model="resource.Password" name="Password" />...

How select an item from dropdown list in angularjs?

javascript,php,angularjs,select,angularjs-ng-model
How select an item from dropdown list in angularjs,Here I am using normal select list but not from object array. If I am using ng-repeat then I can select one, but here how can I do the same? <select class="form-control" ng-model="range" ng-change="updateRange()"> <optgroup label="Current"> <option value="1.1">Today</option> <option value="1.2">This Week</option> <option...

Don't have access to attribute in my controller Angular.js 1.3

javascript,angularjs,mongoose,angularjs-ng-model
I'm building a simple form. This form get a birthday field. I can select a date and persist it. But when I reload the page, I have an error Error: [ngModel:datefmt] Expected `2015-03-06T23:00:00.000Z` to be a date I know how to resolve it. I need to convert my user.date_birthday to...

Radio buttons in nested ng-repeat

javascript,angularjs,radio-button,angularjs-ng-repeat,angularjs-ng-model
I am new to angular and I was stuck on an issue where I have a nested ng-repeat inside an ng-repeat as follows: <div ng-repeat="question in main.questions"> <div class="row"> <br/><span>Q{{$index+1}}. {{question.Ques.questiontxt}}</span> </div> <div ng-repeat="answer in question.Answer"> <input type="radio" name="question{{$parent.$index}}" value="{{answer.answertxt}}{{$parent.$index}}"/> {{answer.answertxt}} </div> </div> Here, main.questions is an array of questions....

ng-click to execute after ng-model changes

javascript,angularjs,angularjs-ng-model
I was wondering if there was a way I could have a ng-click function which takes in a scope variable execute after the value of the ng-model of that same scope variable changes. I have a list of analysis objects in a list called analyses that have (among others) an...

ng-model in ng-repeat; get value of ng-model

javascript,angularjs,ng-repeat,angularjs-ng-model
I have following weird situation - Controller snippet - $scope.filterNum = {0: 'filterVal1', 1: 'filterVal2', 2: 'filterVal3', 3: 'filterVal4', 4: 'filterVal5', 5: 'filterVal6', 6: 'filterVal7', 7: 'filterVal8', 8: 'filterVal9', 9: 'filterVal10', 10: 'filterVal11', 11: 'filterVal12', 12: 'filterVal13', 13: 'filterVal14', 14: 'filterVal15', 15: 'filterVal16', 16: 'filterVal17', 17: 'filterVal18'}; $scope.operatorNum = {0:...

How do I get an input value into Angular's $scope?

javascript,angularjs,angularjs-scope,angularjs-ng-model
I'm new to Angular, and I am trying to do something really basic. Here is a part of a view (all angular files are added elsewhere) : <div ng-controller='ctrl'> <input type='text' ng-model='id'> </div> And here is my controller : module.controller('ctrl',['$scope', function ($scope) { // get the scope value here }]);...

Number of objects in a ng-repeat that is filtered [duplicate]

javascript,angularjs,angularjs-ng-repeat,ng-repeat,angularjs-ng-model
This question already has an answer here: How to display length of filtered ng-repeat data 6 answers I'm using angularjs in a site and there I have a search input that filters a list on a view. This list is displayed with a ng-repeat that has a filter from...