Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.form.valueChanges.subscribe(data => console.log('form changes', data));
- <section>
- <div>
- <form [formGroup]="form">
- <fieldset>
- <div class="panel-group m-l-1 m-r-1 accordion vertical-scroll" id="">
- <div class="form-group required no-gutter">
- <label for="firstname" > First Name:</label>
- <div class="col-md-7 col-lg-6">
- <input type="text" class="form-control" id="firstname" placeholder="" name="firstname" title="firstname"
- formControlName="firstname" size="128" aria-required="true" maxlength="35">
- </div>
- </div>
- </fieldset>
- <div>
- <button class="btn btn-primary" type="button" (click)="save()" >Save</button>
- <button class="btn btn-primary" type="button" (click)="cancel()">Cancel</button>
- </span>
- </div>
- </form>
- </div>
- </section>
- export class ProfileComponent implements OnInit, AfterViewInit, OnChanges {
- public form: FormGroup;
- constructor(private formBuilder: FormBuilder, private app: Application) {
- }
- loadForm(): void {
- this.form = this.formBuilder.group({
- firstname: [this.app.firstName, Validators.required]
- });
- this.form.valueChanges.subscribe(data => console.log('form changes', data));
- }
- save(): void {
- }
- cancel(): void {
- };
- ngOnInit() {
- this.loadForm();
- }
- ngAfterViewInit() {
- this.loadForm();
- }
- }
- this.form.valueChanges
- .skip(1)
- .subscribe(data => console.log('form changes', data));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement