Questions tagged [angular2-ngmodel]

Angular 2's ngModel directive used for two-way databinding

209 questions
13
votes
3 answers

Angular 4 - How to use currency pipe in input type

I have an HTML input: I want to format its value and use an existing pipe: .... [(ngModel)]="item.value | currency:'USD':true" ..... Also I'm trying to use it the following way, but…
Mahendra Waykos
  • 666
  • 2
  • 7
  • 18
12
votes
4 answers

How to change the date format in the datepicker of Angular ngx-bootstrap inside a form

Using ngx-bootstrap Datepicker in an Angular 4 application, I know that normally you can specify the date format this way: but…
Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252
12
votes
9 answers

"Trim" directive for angular 2 and reflect changes to ngModel

I want to create Angular 2 directive that will tirm spaces only from begining and the end of the text that user has typed into input field. I have input field and directive import {Directive,…
misterGrosar
  • 294
  • 1
  • 3
  • 10
12
votes
3 answers

Angular2 ngModel inside of ngFor

I am trying to bind an array of strings from my inputs, so in the html file I wrote this:
Mehdi Benmoha
  • 3,694
  • 3
  • 23
  • 43
10
votes
5 answers

Angular 2: Default checked on checkbox in ngFor

I'm trying to set default value as checked on a checkbox inside my ngFor. This is my array of checkbox items: tags = [{ name: 'Empathetic', checked: false }, { name: 'Smart money', checked: true }, { name: 'Minimal help after writing…
Martin Brandhaug
  • 1,052
  • 1
  • 10
  • 21
10
votes
1 answer

Angular 2: Using pipes with ngModel

I was using JQuery inputmask in one of my forms along with [(ngModel)], but for some reason they won't work together. Using either one by itself works perfectly fine, but combining the two completely breaks [(ngModel)] and new inputs don't get sent…
Bryan
  • 2,951
  • 11
  • 59
  • 101
9
votes
4 answers

(ngModelChange) does not update the UI for specific input

I have an input field where the user can enter the rate of something. When the user enters a value, I want it to be displayed after rounding it off and then the updated value to be stored on the backing model in ts file. Using an Angular pipe isn't…
Yogesh
  • 699
  • 1
  • 6
  • 21
9
votes
3 answers

Angular2/4 mat-select multiple ngModel

I have a mat-select dropdownlist with multiple enabled and am using NgModel to store user selected values. Problem is when I navigate to another page and come back the user-selected values aren't in the mat-select..I know the ngModel has those…
Ram
  • 527
  • 1
  • 10
  • 26
7
votes
2 answers

ErrorHandler in Angular2

I have a question about new class ErrorHandler (was included to RC.6). I did example from official docs: https://angular.io/docs/ts/latest/api/core/index/ErrorHandler-class.html import{ErrorHandler} from "@angular/core"; import{NgModule} from…
Egor
  • 2,122
  • 2
  • 21
  • 23
6
votes
2 answers

RadioButton ngmodel not working for boolean values

I have two radio buttons in Sample with ngModel.
6
votes
2 answers

Angular 6 how to pass selected checkbox to ngModel

I have problem with pass selected checkbox (which is iterated) to ngModel. in ts I have model: testData =…
emka26
  • 433
  • 1
  • 11
  • 28
6
votes
4 answers

Angular 2 - ngModel with dynamic object/properties

In my TS file I am dynamically creating the properties on my selectedValsObj object like this: private selectValsObj: any = {}; setSelectedValsObj(sectionsArr) { sectionsArr.forEach(section => { section.questions.forEach(questionObj => { …
georgej
  • 3,041
  • 6
  • 24
  • 46
6
votes
1 answer

Using Angular ngmodel without name attribute

I am just reading and learning Angular2 tutorial. Here it says "Defining a name attribute is a requirement when using [(ngModel)] in combination with a form." However, in the tutorial, it is using ngmodel without a name attribute here.
6
votes
3 answers

Setting value of [(ngModel)] upon first page load in Angular 2

I am trying to create a simple select component which takes in some data via attributes and renders the required options. I plan to use this select component inside the template of another component, say PageComponent's template( page.template.html…
Praveen Puglia
  • 5,577
  • 5
  • 34
  • 68
6
votes
3 answers

Angular2 selected option with objects

I have an Angular 2 app that is dealing with customers and a spring rest back end. The customer object has a customer type, which is also an object, and I have the drop down on the customer form working so that objects are stored as the value,…
Drew
  • 464
  • 1
  • 5
  • 18
1
2
3
13 14