angularjs-ng-model

Angular 4 ngModel between components

一曲冷凌霜 提交于 2020-01-15 10:14:18
问题 I'm trying to filter my products by categoryId value. Products are listing in product-component. I have a categoryFilter pipe that filters Products and returns list of Product. This pipe requires categoryId but this value is in category-component scope. So my product-component cannot access it. What should I do to make it work? product-component.html <ul class="list-group"> <li class="list-group-item" *ngFor="let product of products |productFilter:filterText|categoryFilter:filterCategory">

ngModel without providing model name in angular 2

吃可爱长大的小学妹 提交于 2020-01-13 07:18:30
问题 <input #gb type="text" pInputText class="ui-widget ui-text" ngModel (ngModelChange)="clearFilter($event)"> I didn't assign any model name to ngModel directive in my code, but Angular 2 accepts this, while AngularJS (1.x) doesn't. Which scenario we need to use this kind of ngModel directive without providing model name? 回答1: Angular 2 accepts it because the object could be set later. A proper way of coding this would be to check if the object exists first, and only then show the object if it

ngModel without providing model name in angular 2

我的梦境 提交于 2020-01-13 07:18:13
问题 <input #gb type="text" pInputText class="ui-widget ui-text" ngModel (ngModelChange)="clearFilter($event)"> I didn't assign any model name to ngModel directive in my code, but Angular 2 accepts this, while AngularJS (1.x) doesn't. Which scenario we need to use this kind of ngModel directive without providing model name? 回答1: Angular 2 accepts it because the object could be set later. A proper way of coding this would be to check if the object exists first, and only then show the object if it

Value in ng-model doesn't update

为君一笑 提交于 2020-01-06 20:18:56
问题 I'm using this <textarea class="notes" placeholder="Placeholder Text" style="height: 630px;" ng-model="notes"></textarea> and from what I can understand ng-model="notes" means that the textarea is assigned whatever $scope.notes is. This works correctly, however whenever I edit the text in the textarea, isn't $scope.notes supposed to change as well? When I use this button: <button ng-click="saveNotes(notes)"></button> The value of "notes" is always the original $scope.notes value and not the

How to set checkbox ng-checked from server data using AngularJS and save the checked/unchecked back to server data?

六眼飞鱼酱① 提交于 2020-01-06 18:05:11
问题 This should be a very common problem, invoking an ng-model to parse the data into form (DOM) after which the modified checkbox's ng-checked will be translated back to data values so to be saved back on the server. I have two check boxes respectively <table><tbody> <tr> <td align="left">To be ignored</td><td align="left">Yes <input type="checkbox" ng-model="nm_ignore" /></td> <td></td> </tr> <tr> <td align="left">To be excluded</td><td align="left">Yes <input type="checkbox" ng-model="nm

Angular CLI - Please add a @NgModule annotation when using latest

橙三吉。 提交于 2020-01-01 00:58:06
问题 note: I'm new to Angular, so please excuse any new comer stupidity here. Details I've installed the latest version of Angular CLI The default app loads and runs perfectly fine after 'ng serve' Issue I decided to create a new module an import it into the app module This is something I've done a couple of times in Angular 2 and it's worked perfectly fine However, since I ran the latest version of Angular CLI this morning, importing a module breaks and I receive the following error: compiler.es5

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

孤者浪人 提交于 2019-12-30 08:19:31
问题 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 }]); What I'm trying to do is really simple. I'd like to use the input value. I tried something like $scope.data = [] and $scope.data.push($scope.id) to create an array with the scope

Connect radial input and text input

 ̄綄美尐妖づ 提交于 2019-12-25 08:58:38
问题 I have form with radial buttons but the last one is a combination of radial button and text input. I want to somehow connect the two inputs. User should not be able to input the text before clicking the radial button next to it. Also when user starts to write text I wanna stop the radial button checked indication from disappearing. If user clicks some other radial button the text field should empty itself. <label class="form-check-label"> <input type="radio" name="religion" value="noSay" ng

ng-model won't update the changed form content

时光怂恿深爱的人放手 提交于 2019-12-25 06:24:24
问题 I have a form which has a delete entry button and an add entry button. I want to output the updated form field data to formData={} , so that the submitted data will be up-to-date. However, when a fieldset is deleted, formData={} is not updated with the newest data entry information and the old form data still exist in formData={} . Here's the link for my code 回答1: try like this. var app = angular.module("app",[]); app.controller("MyCtrl" , function(){ var formCtrl = this; formCtrl.forms ={

Is it possible to bind and unbind an element on button click? - AngularJS

痞子三分冷 提交于 2019-12-25 02:48:15
问题 I created a display text and an input field and bind them together with ng-model as follow. HTML <div ng-app ng-controller="test"> <div ng-bind="content"></div> <input id="txtElem" type="text" ng-model="content"> <button ng-click="stopBinding()"> Unbind</button> <button ng-click="binding()"> Bind </button> </div> JS function test( $scope ) { $scope.content = 'Welcome'; $scope.binding = function() { angular.element(document.getElementById('txtElem')).bind(); }; $scope.stopBinding = function()