angular-forms

Extending FormControlDirective in Angular 2+

限于喜欢 提交于 2019-12-11 04:58:00
问题 I'm looking at this question, trying to figure out how to extend FormControlDirective: Attempting to extend FormControlDirective to implement my own FormControl directive results in faulty binding. There is an answer, but I'm not sure what is meant by: The formControl \ formControlName selectors appear in one more place - the value accessor. In order your directive to work you should implement all default value accessors for the hybridFormControl directive ( following the pattern for the

Set Value Not Less Than 0 In FormArray Reactive Forms

二次信任 提交于 2019-12-11 04:29:14
问题 I have successfully implemented the value in the input field to not less than 1 in the "quantityControl" formControlName. However my problem is when on the formArray. How can i set that to not than less than 0 or should not be a negative number? Here's the code below and the link to my stackblitz CODE LINK this.inquiryForm.get('quantityControl').valueChanges.pipe( filter(quantity => quantity < 1) ).subscribe(value => { console.log(value); this.inquiryForm.get('quantityControl').setValue(1); }

Angular 5: Dynamic Form Validation inside a table

十年热恋 提交于 2019-12-11 02:58:30
问题 I am trying to validate input fields inside a table using form group but unable to achieve the same. I am using *ngFor to iterate the data because I have to display that data in the first column of the table and other columns are just input text fields in which I have to add form validation. So I have added the index for the unique form control name for the field. HTML code <form [formGroup]="tableForm"> <table class="shop-table table-responsive" cellspacing="0"> <tbody> <tr class="cart_item"

AngularDart: Creating a Form with Reactive Form Builder

╄→尐↘猪︶ㄣ 提交于 2019-12-10 17:25:34
问题 I'm trying to create from using AngularDart 5 , angular_forms 2 . The API seems to be very different from angular_forms 1 and I cannot figure out how to create a FormGroup using FormBuilder and ControlGroup . Below is my code. LoginComponent.dart import 'dart:convert'; import 'package:angular/angular.dart'; import 'package:angular_forms/angular_forms.dart'; @Component( selector: 'login-comp', templateUrl: 'login_component.html', styleUrls: ['login_component.css'], directives: [formDirectives,

control.setParent is not a function when dymanically creating formGroup

独自空忆成欢 提交于 2019-12-10 15:48:24
问题 I'm using Angular5, and I have a list of fields, each has a name and FormControl. I try to dynamically add the controls to the group, using this code, but I got an error. const formControlFields = [ {name: 'field1',control: [null, []] as FormControl}, {name: 'field2',control: [null, []] as FormControl} ]; const formGroup: FormGroup = new FormGroup({}); formControlFields.forEach( f => formGroup.addControl(f.name,f.control)); this.form = new FormGroup({groups:formGroup}); This is the error I

Angular 6: Can't bind to 'formGroup' since it isn't a known property of 'form'?

本小妞迷上赌 提交于 2019-12-10 12:34:58
问题 I have worked with form builder in angular 2/4, But now I am using it in angular 6. I have seen this question (Can't bind to 'formGroup' since it isn't a known property of 'form') but it was for angular 2. I doing exact same against angular 4 but I am getting this error. Please help: my code are: app.module.ts: ( I have exported FormsModule & ReactiveFormsModule) : import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { LocalStorage } from

Can't bind to 'ngValue' since it isn't a known property of 'option'

醉酒当歌 提交于 2019-12-10 01:02:36
问题 I am trying to implement select in Angular 5 but I am constantly getting this I've tried many StackOverflow questions already, The only difference is - My components are inside another module within the application which is at the end injected into the main module eventually. I've also tried injecting the FormsModule inside the inner module. I have tried importing ReactiveFormsModule but didn't work. I've added FormsModule to imports like this import { BrowserModule } from '@angular/platform

Angular 2 Material input focus not working

对着背影说爱祢 提交于 2019-12-09 02:54:50
问题 The inputs are inside of a modal dialog. I have no idea why it is not working. I looked at the official docs and it listed focus as something you can pass to the element but it's not working? Does anyone know why? Angular Material - Input Docs <form class="example-form"> <md-input-container class="example-full-width" style="width: 300px; padding: 5px; border-radius: 10px;"> <input mdInput type="email" name="to" placeholder="Email"> <md-error></md-error> </md-input-container> <md-input

How to disable all the fields in a template driven form in angular

自闭症网瘾萝莉.ら 提交于 2019-12-08 16:55:23
问题 I created a template driven form in angular 5 I want to disable the whole form at first, and also want the form to be enabled once some button is clicked, Hence I added a disabled property in the form tag and made its value as false as shown below , (this didn't work though): <form #formName = "ngForm" [disabled]="true"> </form> As the above disabled property didn't work, I changed the disabled property as [attr.disabled] = true This also didn't work Now as I have the form element's reference

Web workers in angular 6

一世执手 提交于 2019-12-08 10:50:44
问题 I am using angular 6. I want to load 100 rows in my grid but this 100rows contains lots of data so while loading this data in my angular application it's hangs the browser. So currently I changed into 20rows per page I am using remote pagination. But I have a requirement to load 100rows in my application. So I tried to implement the WebWorkers. But I didn't find any examples. Can someone give me the example or steps to implement WebWorkers in angular 6 Also I am using reactive formarray for