我要捕获为变量的Angular Form New Field,并在提交后添加到新的SharePoint列表中

时间:2018-10-26 04:11:36

标签: angular

我有一个承包商为我们建造的应用程序,然后使用Angular离开了。我已经能够修改和改造许多代码来使其实现我们想要的功能,但是我对Angular还是很陌生,所以我不确定如何处理下一个任务。

我有一个新字段,我将其添加到应用程序中的一个表单中。

 <div class="form-group">
                    <mat-form-field class="col-md-6">
                        <input matInput class="form-control" 
                                id="LearnerWWID" 
                                type="text" 
                                placeholder="WWID" 
                                value=''
                                formControlName="LearnerWWID"/>
                    </mat-form-field>
                </div>

这是提到新字段的地方。我想在component.ts代码的此部分中捕获此值:

saveRequest(): void {
console.log('TrgAROneComponent -> saveRequest');
if (this.requestFormTrgAROne.dirty && this.requestFormTrgAROne.valid) {
    // Copy the form values over the product object values
    const p = Object.assign({}, this.requestFormTrgAROne.value);
    this.selTraining = this._requestService._trgUgInv.filter(trg =>
      trg.TrainingCode.toLowerCase() === p.Training.toLowerCase ||
      trg.UserGroupName.toLowerCase() === p.UserGroupName.toLowerCase())[0];
      console.log('TrgAROneComponent -> saveRequest-> this.selTraining', this.selTraining);
    p['TrainingName'] = this.selTraining.TrainingName;
    p['UserGroupName'] = this.selTraining.UserGroupName;
    p['AddWWIDApprovalReq'] = this.selTraining.AddWWIDApprovalReq;
    p['RemoveWWIDApprovalReq'] = this.selTraining.RemoveWWIDApprovalReq;
    p['AudienenceIDGrpOwners'] = this.selTraining.AudienenceIDGrpOwners;
    p['ReqSupportMailbox'] = this._requestService._selReq.ReqSupportMailbox;
    p['ProcessingMailbox'] = this.selTraining.ProcessingMailbox;
    p['RequesterName'] = this._requestService._userProfile.DisplayName;
    p['RequesterEmail'] = this._requestService._userProfile.Email;
    p['RequesterWWID'] = this._requestService._userProfile.WWID;
    p['ReqContentTypeId'] = this._requestService._selReq.ReqContentTypeId;
    p['SharedApprovalMailbox'] = this.selTraining.SharedApprovalMailbox;
    p['LearnerWWID'] = what goes here?  
    // Decide if approval is required
    p['IsApprovalReq'] = this.isApprovalRequired(p);
    console.log('TrgAROneComponent -> saveRequest-> p', p);
    this._trgaroneService.saveRequest(p).subscribe(
      result => {
        console.log('TrgAROneComponent ->saveRequest- > result', result);
        // this.requestFormTrgAROne.reset();
        this.router.navigate(['/reqmgmt/confirm']);
      },
      error => {
        this.errorMessage = error;
        console.log('TrgAROneComponent ->saveRequest- > error', error);
      }
    );
}

}

任何建议都会有所帮助。

此致

亚当

0 个答案:

没有答案