asp.net core angular 如何往服务端传集合数据

请问一下angular HttpClient post往服务器端传数据时如何传集合,不用序列成字符串,然后再反序列的方式
服务端:

    [HttpPost("create")]
    public async Task<long> InsterSysOrgTypeAndFunction(List<SysOrgTypeAndFunction> sysOrgTypeAndFunctions)
    {
        return 0;
        //return await Task.Run(() => new DSysOrgTypeAndFunction(Configuration.GetConnectionString("DefaultConnection")).Insert(sysOrgTypeAndFunction));
    }

客户端:
import { Injectable } from "@angular/core";
import { HttpClient, HttpParams } from "@angular/common/http";
import { Observable } from "rxjs/Observable";

@Injectable()
export class SysOrgTypeAndFunctionService {
constructor(private http: HttpClient) { }

// 查询信息
getSysOrgTypeAndFunctions() {
    return this.http.get<any>('api/SysOrgTypeAndFunction/get-users');
}

//
// 保存信息
//
SaveSysOrgTypeAndFunction(formData: FormData, operation: Operation) {

    switch (operation) {
        case Operation.Create:
            return this.http.post<boolean>('api/SysOrgTypeAndFunction/create', formData)
                .catch(this.errorHandler);
        case Operation.Modify:
            return this.http.post<boolean>('api/SysOrgTypeAndFunction/modify', formData)
                .catch(this.errorHandler);
        case Operation.Delete:
            return this.http.post<boolean>('api/SysOrgTypeAndFunction/delete', formData)
                .catch(this.errorHandler);
    }
}

errorHandler(error: Response) {
    console.log(error);
    return Observable.throw(error);
}

}

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问