angular-forms

Dynamic Columns Reactive Forms in Angular

て烟熏妆下的殇ゞ 提交于 2019-12-08 07:16:54
问题 How can i add several columns if i add the "click here to add transportation field" like i want to add driver, contact number etc.... Once you click the modal, it will show you some options on what field to add. Please check the code link that I've made. here's also my codes below. Please check also the image here CHECK THIS LINK https://stackblitz.com/edit/dynamic-columns-reactive-forms-hj5nur?file=app/app.component.ts openModal(template: TemplateRef < any > ) { this.modalRef = this

Dynamic Columns Reactive Forms in Angular

自古美人都是妖i 提交于 2019-12-08 06:18:26
How can i add several columns if i add the "click here to add transportation field" like i want to add driver, contact number etc.... Once you click the modal, it will show you some options on what field to add. Please check the code link that I've made. here's also my codes below. Please check also the image here CHECK THIS LINK https://stackblitz.com/edit/dynamic-columns-reactive-forms-hj5nur?file=app/app.component.ts openModal(template: TemplateRef < any > ) { this.modalRef = this.modalService.show(template); } initGroup() { let rows = this.addForm.get('rows') as FormArray; rows.push(this

Setting errors on a FormGroup instance in Angular Reactive Forms not working as expected

时光毁灭记忆、已成空白 提交于 2019-12-07 23:21:22
问题 I'm using Angular 4.4.3 reactive forms to implement custom validation for a group of controls in a form. The method AbstractControl.setErrors, according to docs updates the errors property of the AbstractControl, upon which it's invoked, updates the status of its parent, but not the parents errors property. I wanted to set the errors property on a FormGroup instance, so I use the setErrors inherited by the FormGroup. However, it does not update errors as expected. Following is my sample code:

Form Builder with hasError() for validation throws an error of ERROR TypeError: Cannot read property 'hasError' of undefined

↘锁芯ラ 提交于 2019-12-06 20:19:11
问题 Hi I am implementing a form in angular 2 using Form Builder in component.ts i have implemented my form using formGroup Below is My code public myForm: FormGroup; constructor(private authenticateservice: AuthenticateService, private _fb: FormBuilder ) { } ngOnInit() { this.myForm = this._fb.group({ address: [this.userDetails.address, [<any>Validators.required]], address2: ['', [<any>Validators.required]], city: ['', [<any>Validators.required]], company_address: ['', [<any>Validators.required]]

How to get checkbox value in angular 5 app

人走茶凉 提交于 2019-12-06 15:55:13
I am working on Angular checkbox and need to read value either given ng-true-value / ng-false-value or boolean value not sure what I am missing from code. I am reading event but not sure which value to read?? template <div> <input type="checkbox" name="questionAnswerState" ng-model="check" ng-true-value = "answerProvided" ng-false-value="questionAnswerNotProvided" (change)="isAnswerProvided($event, check)" /> Answer Provided? component isAnswerProvided(event: any, check:any) { console.log("question answer not provided responseId:: ",this.responseId, " questionId::",this.questionId, " check::",

Angular: how to make NgControl react to valueChanges only of the host <input>

你离开我真会死。 提交于 2019-12-06 15:29:28
I am using a directive on an <input> -element and get a reference to its controls like this: @ContentChild(NgControl) private readonly _inputNgControl: NgControl; But when I listen to model-changes like so: ngAfterContentInit(): void { this._inputNgControl.control.valueChanges .distinctUntilChanged() .subscribe(value => { // ... }); } it appears that this._inputNgControl.control refers not to the input that the directive is sitting on, but to ALL inputs in my parent component (which contains multiple <input> -elements with the same directive) because I get changes from all of those inputs in

No provider for NgForm error in dev mode using Angular 4.4.6

人盡茶涼 提交于 2019-12-06 09:53:22
EDIT: I've discovered what is causing the problem; I'm now looking for a solution as to how to cater for it. NOTE : This issue is happening in dev mode (i.e. not prod, and not using aot) I'm using the "Update" solution from here: https://stackoverflow.com/a/46324043/3164070 To solve an issue with an input in a child component that was not updating the valid flag on the form. It works in a fairly simple test project, however when moving it to our real project, it throws this error: core.es5.js:1020 ERROR Error: Uncaught (in promise): Error: No provider for NgForm! Error: No provider for NgForm!

Correct way to integrate reCAPTCHA with Angular 4

寵の児 提交于 2019-12-06 08:08:47
I'm trying to integrate an Invisible reCAPTCHA with my Angular 4 form. In the TS part of the component I have a function like this: onSubmit(token: string) { alert(token); } And my HTML looks like this (only the relevant parts shown): <form (ngSubmit)="onSubmit()" #myForm="ngForm"> <button type="submit" class="btn g-recaptcha" data-sitekey="mykey" data-callback="onSubmit">Submit</button> </form> When clicking on that button I get either an alert saying the token is undefined, or I get an error message like this: "Cannot contact reCAPTCHA. Check your connection and try again." Not really

Setting errors on a FormGroup instance in Angular Reactive Forms not working as expected

£可爱£侵袭症+ 提交于 2019-12-06 08:07:27
I'm using Angular 4.4.3 reactive forms to implement custom validation for a group of controls in a form. The method AbstractControl.setErrors , according to docs updates the errors property of the AbstractControl, upon which it's invoked, updates the status of its parent, but not the parents errors property. I wanted to set the errors property on a FormGroup instance, so I use the setErrors inherited by the FormGroup. However, it does not update errors as expected. Following is my sample code: Trying it on FormControl instances, does update their errors as well as their parents' validity

Angular 5 form validation (required) not working

浪子不回头ぞ 提交于 2019-12-05 22:43:50
I am learning Angular 5 with TypeScript. I am completely new to it. I am now trying to construct a form and validating it. But it is not working properly. Please see my code below. This is my component. @Component({ selector: 'app-login', templateUrl: './login.component.html', styleUrls: ['./login.component.scss'], animations: [routerTransition()] }) export class LoginComponent implements OnInit { loginForm: FormGroup; errors = []; constructor(private fb: FormBuilder, public router: Router, private globals: GlobalsService, private http: Http) { } ngOnInit() { this.loginForm = new FormGroup({