Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. this.form.valueChanges.subscribe(data => console.log('form changes', data));
  2.  
  3. <section>
  4. <div>
  5. <form [formGroup]="form">
  6. <fieldset>
  7. <div class="panel-group m-l-1 m-r-1 accordion vertical-scroll" id="">
  8. <div class="form-group required no-gutter">
  9. <label for="firstname" > First Name:</label>
  10. <div class="col-md-7 col-lg-6">
  11. <input type="text" class="form-control" id="firstname" placeholder="" name="firstname" title="firstname"
  12. formControlName="firstname" size="128" aria-required="true" maxlength="35">
  13. </div>
  14. </div>
  15.  
  16. </fieldset>
  17. <div>
  18. <button class="btn btn-primary" type="button" (click)="save()" >Save</button>
  19. <button class="btn btn-primary" type="button" (click)="cancel()">Cancel</button>
  20. </span>
  21. </div>
  22. </form>
  23. </div>
  24. </section>
  25.  
  26. export class ProfileComponent implements OnInit, AfterViewInit, OnChanges {
  27. public form: FormGroup;
  28.  
  29. constructor(private formBuilder: FormBuilder, private app: Application) {
  30.  
  31. }
  32.  
  33. loadForm(): void {
  34. this.form = this.formBuilder.group({
  35. firstname: [this.app.firstName, Validators.required]
  36. });
  37. this.form.valueChanges.subscribe(data => console.log('form changes', data));
  38.  
  39. }
  40.  
  41. save(): void {
  42.  
  43. }
  44.  
  45. cancel(): void {
  46.  
  47. };
  48.  
  49. ngOnInit() {
  50. this.loadForm();
  51. }
  52.  
  53. ngAfterViewInit() {
  54. this.loadForm();
  55. }
  56.  
  57.  
  58. }
  59.  
  60. this.form.valueChanges
  61. .skip(1)
  62. .subscribe(data => console.log('form changes', data));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement