如何使用来自后端API或服务的数据填充Angular7 react Form

时间:2019-01-13 12:30:07

标签: javascript angular7

使用Angular和Laravel创建CRUD应用程序时,如何在创建应用程序的更新模块时填充Angular React Form组件

我尝试传递来自API的接收数据。使用以下代码

ngOnInit() {

       this.route.paramMap.subscribe((params: ParamMap) => {
                  const id = parseInt(params.get('id'), 10);
                  this.viewID = id;
                  });
   this.dashboardeditService.dashbordContent(this.viewID).subscribe(post => {
   this. _contents = post;
   this.myForm = this. _contents;
   console.log(this. _contents);
        } );
      // this.pageEdit.patchValue(this._contents);
      this.pageEdit = new FormGroup({
        title: new FormControl('', Validators.required),
        menu: new FormControl('', Validators.required),
        body: new FormControl('', Validators.required),
        picture: new FormControl(''),
      });

0 个答案:

没有答案