import { Component, OnInit, Inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import {MatDialogRef} from '@angular/material/dialog'; @Component({ selector: 'addenterpriseuser', templateUrl: './addenterpriseuser.component.html', styleUrls: ['./enterpriseuser.component.scss'] }) export class AddEnterpriserUser { constructor(private http: HttpClient,public dialogRef: MatDialogRef) {} errmsg:any; //捕获错误信息 //提交创建表单 onSubmit (e) { let date = new Date() this.http.post('/api/CompanyUsers',{ name:e.loginName, phone:e.tel, enabled:true, creationTime:date, usci:e.creditcode, companyName:e.unitname }).subscribe(data=>{ this.dialogRef.close(data)}, error=>{this.errmsg=error} ) } }