angular-ngmodel

Multiple ng-models on one input field?

陌路散爱 提交于 2019-12-02 20:50:03
I have a form, and a list of items. I used ng-model="searchFor" to filter out the list of items appropriately (this part is working fine), but I also want to "submit" the item that's filtered out -- which would require ng-model="adding_item.name" on the input field as well (I think). Can you have multiple ng-models on one input field? Is there another way around this? Try using ng-change event to capture model value and assign it to other input element with its own ng-model. <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app> <input type=

What is purpose of using forRoot in NgModule?

て烟熏妆下的殇ゞ 提交于 2019-12-02 20:07:56
What is the purpose of using forRoot in NgModule? Is it same as the providers in AngularJS 1.x? How does it play the significant role in lazy loading? TIA. It has to do with singletons. Angular services are loaded onto the page 1 time (singleton) and all references point back to this 1 instance. There is a risk that a lazy loaded module will try to create a 2nd instance of what should be a singleton, and the forRoot() method is a way to ensure that the app module / shared module / and any lazy loaded module all use the same 1 instance (the root instance). More info copied from: Provide core

Combine a variable with variable value in Javascript

蹲街弑〆低调 提交于 2019-12-02 18:19:33
问题 I am trying to do something like this in Angular javascript (a simplified code): var modelName = "date"; if (attrs.hasOwnProperty('today')) { scope.modelName = new Date(); } In the above, I actually want scope.modelName to become scope.date automatically. How can I parse the modelName variable to its value? 回答1: You can access properties of objects using square brackets. var modelName = "date"; if (attrs.hasOwnProperty('today')) { scope[modelName] = new Date(); } 来源: https://stackoverflow.com

Add boolean checkboxes ng-model to object AngularJS

纵然是瞬间 提交于 2019-12-02 13:01:17
问题 I am trying to do something like tree-checkboxes. I would like to add boolean to children of checked name : ex. after click checkbox at name : eva - all her childrens will be also checked. Like that : $scope.messages = { "family": [ { "name": "eva", "checked" : true, "childrens": [ { "name": "John", "checked" : true, "childrens": [ { "name": "Jacob", "checked" : true, } My code : <div ng-repeat="key in messages"> <ul ng-repeat=" (x, y) in key" style="list-style:none;"> <li> <input type=

AngularJS ng-value and ng-model do not work together [duplicate]

隐身守侯 提交于 2019-12-02 11:14:52
This question already has an answer here: What's the difference/incompatibility between ng-model and ng-value? 5 answers I was trying to give a value to textfield using ngvalue and textarea has that value but it when I submit it, it recognized as textarea is empty. <textarea ng-value="main.record.basic_info.application_letter" class="form-control" ng-model="main.record.apply_job.cover_letter" name="name" rows="15" cols="80" style="resize: none"> </textarea> You cannot use these directives together "It can also be used to achieve one-way binding of a given expression to an input element such as

Add boolean checkboxes ng-model to object AngularJS

为君一笑 提交于 2019-12-02 04:31:10
I am trying to do something like tree-checkboxes. I would like to add boolean to children of checked name : ex. after click checkbox at name : eva - all her childrens will be also checked. Like that : $scope.messages = { "family": [ { "name": "eva", "checked" : true, "childrens": [ { "name": "John", "checked" : true, "childrens": [ { "name": "Jacob", "checked" : true, } My code : <div ng-repeat="key in messages"> <ul ng-repeat=" (x, y) in key" style="list-style:none;"> <li> <input type="checkbox" ng-model="y.check" ng-change="changeValue(shapes, y.name)" /> {{y.name}} {{y.check}}</li> <li

Angular: Show div content depending on which option chosen from drop down menu (ng-show/ng-switch)

只谈情不闲聊 提交于 2019-12-02 04:27:06
问题 So I'm completely new to front end (angular, bootsrap, etc), but I have here a JSFiddle link that I created, and what I am trying to do is basically if someone chooses the option "VA" in the drop-down menu, I want to use the appropriate ng (switch or show), and show the div class with the same name, in this case the div class="VA" If they choose NY, I want it to show the div-class="NY", and not the VA div (in my example I only have two options, but I will have around varying options in my

AngularJS - ngmodel in ngrepeat not updating ('dotted' ngmodel)

浪尽此生 提交于 2019-12-02 01:19:48
问题 i'm trying to draw radioBoxes with angular array, and after that get value of checked radio, but model don't change its value you, can anyone help me with this ? HTML part <div ng-app> <div ng-controller="CustomCtrl"> <label ng-repeat="user in users"> <input type="radio" name="radio" ng-model="radio" value="{{user.name}}" /> {{user.name}} </label> <br/> {{radio}} <br/> <a href="javascript:void(0)" ng-click="saveTemplate()">Save</a> </div> </div> Angular Part function CustomCtrl($scope) {

ng-options filter by value in another dropdown

南笙酒味 提交于 2019-12-01 21:43:17
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 in models | filter:{make:makeng}"> <option ng-disabled="true" ng-selected="true" value="">Select a model</option> </select> here is the plunker http://plnkr.co/edit/bHb9AScd2m58acUUyI0t?p=preview Problem

How to manually rerun formatter chain in angularjs directive with ngModel?

北城余情 提交于 2019-12-01 19:32:20
Angular.js ngModel has the ability to declare a chain of parsers and formatters . Some more details can be found at the great answer to 'How to do two-way filtering in angular.js?' now the formatter chain only will be run if the ngModel will update. so if you have a second input-parameter that affects the viewValue (is used in one of the formatters) this will not trigger an update of the View. similar as far as i found ngModel only uses a simple $watch - so if your model is a collection/object it will not trigger if sub-elements are changed. What is the best way to implement a deep watch for