简体   繁体   中英

ASP.NET MVC (WEB API) with angular JS passing strong type parameters

So I have a controller takes strong typed CarModel object for post request. In angular js how do I serialize it and pass with post request so the controller will understand it. Can someone show a sample code or point to a right direction.

I have only seem people posting on how to pass data for angular js to read it, did not find anything talks about how to post a strong typed object.

Thanks

[HttpPost]
[Route("someUrl")]
public IHttpResult PostObject([FromBody]Type name){
    return Ok();
}

And from angular

$http.post("someUrl", myObject);

The javascript object is serialized by angular. The property names just have to match.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM