本節我們主要給大家介紹AngularJs如何調用Restful,實現數據的CRUD。
主要用到的技術:
后端:asp.net WebApi + SQLServer2008
前端:AngularJs,Bootstrap3
主要用到的開發工具
后端:VisualStudio2013 + SQLServer2008
前端:WebStorm8







using System.Net.Http;using System.Web.Http;namespace AngularJs_WebApi_Server.Controllers{ public class TestController : ApiController { public HttPResponseMessage Get() { return new HttpResponseMessage() { Content = new StringContent("我是通過Get請求的") }; } public HttpResponseMessage Post() { return new HttpResponseMessage() { Content = new StringContent("我是通過Post請求的") }; } public HttpResponseMessage Put() { return new HttpResponseMessage() { Content = new StringContent("我是通過Put請求的") }; } }}

測試Get請求http://localhost:31194/api/test
請輸入我們的請求地址和請求方式

查看返回結果

測試Post請求http://localhost:31194/api/test
請輸入我們的請求地址和請求方式

查看返回結果

測試Put請求http://localhost:31194/api/test
請輸入我們的請求地址和請求方式

查看返回結果

(未完待續)
新聞熱點
疑難解答