小编Jam*_*lon的帖子

Angular 6:无法读取未定义的属性'reset'

我在我的方法中使用重置时收到错误.我想保存更改后重置表单但我收到此错误:

在此输入图像描述

这是我的方法:

  @ViewChild('editFrom')
  editForm: NgForm;
  constructor(
    private route: ActivatedRoute,
    private alertify: AlertifyService
  ) {}

  ngOnInit() {

  }
  updateUser() {
    console.log(this.user);
    this.alertify.success('Profile Updated Successfully');
    this.editForm.reset(this.user);
  }
}
Run Code Online (Sandbox Code Playgroud)

这个Html表单:

<form #editForm="ngForm" id="editForm" (ngSubmit)="updateUser()">
              <h4>Description</h4>
              <textarea name="introduction" rows="6" class="form-control" [(ngModel)]="user.introduction"></textarea>
              <h4>Looking For</h4>
              <textarea name="lookingFor" rows="6" class="form-control" [(ngModel)]="user.lookingFor"></textarea>
              <h4>Interest </h4>
              <textarea name="interests" rows="6" class="form-control" [(ngModel)]="user.interest"></textarea>
              <h4>Location Details:</h4>
              <div class="form-inline">
                <label for="city">City:</label>
                <input class="form-control" type="text" name="city" [(ngModel)]="user.city">
                <label for="country">Country:</label>
                <input class="form-control" type="text" name="country" [(ngModel)]="user.country">
              </div>
            </form>
Run Code Online (Sandbox Code Playgroud)

typescript angular angular6

1
推荐指数
2
解决办法
3272
查看次数

标签 统计

angular ×1

angular6 ×1

typescript ×1