angular2-forms

How can I create a pagination component in Angular 4? [closed]

Deadly 提交于 2020-01-01 03:22:16
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago . I have a API endpoint like /list/students?page=5&rows=10 with a pagination parameters page and size . I want to create a angular2 pagination component. Input parameters will be page size In addition, I want to go to specific page and size with arrow buttons. How can I implement this component ? 回答1

Angular 2 Focus on first invalid input after Click/Event

孤人 提交于 2019-12-31 12:18:07
问题 I have an odd requirement and was hoping for some help. I need to focus on the first found invalid input of a form after clicking a button (not submit). The form is rather large, and so the screen needs to scroll to the first invalid input. This AngularJS answer would be what I would need, but didn't know if a directive like this would be the way to go in Angular 2: Set focus on first invalid input in AngularJs form What would be the Angular 2 way to do this? Thanks for all the help! 回答1:

How to Add a Validator dynamically to a FormControl in Angular 2

岁酱吖の 提交于 2019-12-31 09:59:58
问题 I am using ReactiveFormsModule and have defined all my form controls including simple validators such as Validators.required within a const configuration. I wanted to add a custom validator to one of those FormControls. I have currently added the custom validator as a function within this configuration, and it is working fine, but it does not belong here, it really needs to live within my component, but I'm not sure how I can just attach a custom validator manually after the FormBuilder has

How to Add a Validator dynamically to a FormControl in Angular 2

落花浮王杯 提交于 2019-12-31 09:55:20
问题 I am using ReactiveFormsModule and have defined all my form controls including simple validators such as Validators.required within a const configuration. I wanted to add a custom validator to one of those FormControls. I have currently added the custom validator as a function within this configuration, and it is working fine, but it does not belong here, it really needs to live within my component, but I'm not sure how I can just attach a custom validator manually after the FormBuilder has

How to Add a Validator dynamically to a FormControl in Angular 2

本小妞迷上赌 提交于 2019-12-31 09:53:28
问题 I am using ReactiveFormsModule and have defined all my form controls including simple validators such as Validators.required within a const configuration. I wanted to add a custom validator to one of those FormControls. I have currently added the custom validator as a function within this configuration, and it is working fine, but it does not belong here, it really needs to live within my component, but I'm not sure how I can just attach a custom validator manually after the FormBuilder has

How to Add a Validator dynamically to a FormControl in Angular 2

杀马特。学长 韩版系。学妹 提交于 2019-12-31 09:53:09
问题 I am using ReactiveFormsModule and have defined all my form controls including simple validators such as Validators.required within a const configuration. I wanted to add a custom validator to one of those FormControls. I have currently added the custom validator as a function within this configuration, and it is working fine, but it does not belong here, it really needs to live within my component, but I'm not sure how I can just attach a custom validator manually after the FormBuilder has

Angular2 One-way binding form doesn't get cleared after data save

陌路散爱 提交于 2019-12-31 03:46:07
问题 I have a form where inputs are bound to object one-way. <input type="text" name="lastName" #lastName="ngModel" [ngModel]="selectedPers.lastName" required minlength="2"> When saving form I read form data and send it to server, then update my model with dummy/empty data to clear it out. this.peopleListObservable.push(newPersonFormData).then(a => { this.clearPers(); }) clearPers() { this.selectedPers = this.dummyPers; this.isPersAdd = true; } This clear-out method is separate and works when I

Reuse components in angular2 model driven forms

情到浓时终转凉″ 提交于 2019-12-30 04:28:08
问题 I'm fairly new to angular2 and for the past few days I have been trying to create reusable form components using model driven forms So lets say we have a component componentA.component.ts @Component({ selector: 'common-a', template: ` <div [formGroup]="_metadataIdentifier"> <div class="form-group"> <label>Common A[1]</label> <div> <input type="text" formControlName="valueA1"> <small>Description 1</small> </div> <div class="form-group"> <label>Common A[2]</label> <div> <input type="text"

Angular2 reactive form confirm equality of values

末鹿安然 提交于 2019-12-30 02:32:44
问题 I am trying to create an Angular2 Reactive form where I have to confirm the email address entered by the user. Here is a link to the plunker import { Component, OnInit } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { User } from './signup.interface'; @Component({ selector: 'signup-form', template: ` <form novalidate (ngSubmit)="onSubmit(user)" [formGroup]="user"> <label> <span>Full name</span> <input type="text" placeholder="Your full name"

Q: How to use Angular 2 template form with ng-content?

淺唱寂寞╮ 提交于 2019-12-30 00:26:07
问题 Is it not possible to have form input elements within an ng-content and have that "connect" to the ngForm instance of the parent component? Take this basic template for a parent component: <form (ngSubmit)="onSubmit(editForm)" #editForm="ngForm" novalidate> <ng-content></ng-content> <button type="submit">Submit</button> </form> Then inside the child component, which is put inside "ng-content", something like this: <input type="text" [(ngModel)]="user.firstName" #firstName="ngModel" name=