AngularJs調用Restful實現CRUD - AngularJs

來源:互聯網
上載者:User

標籤:

本節我們主要給大家介紹AngularJs如何調用Restful,實現資料的CRUD。

主要用到的技術:

後端:ASP.NET WebApi + SQLServer2008

前端:AngularJs,Bootstrap3

主要用到的開發工具

後端:VisualStudio2013 + SQLServer2008

前端:WebStorm8

1.建立後端項目AngularJs_WebApi1.1建立空解決方案名稱AngularJs_WebApi

1.2 建立AngularJs_WebApi_Server服務端項目

1.3 選擇空的WebApi項目,並建立

1.4 建立控制器TestController類(用於測試)

1.5 編寫TestController.cs實現代碼
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請求的")      };    }  }}

1.6 通過Chrome應用程式REST Console測試剛才發布的服務(如果沒有可以到市集中去下載)

測試Get請求 http://localhost:31194/api/test

請輸入我們的請求地址和請求方式

查看返回結果

測試Post請求 http://localhost:31194/api/test

請輸入我們的請求地址和請求方式

查看返回結果

測試Put請求 http://localhost:31194/api/test

請輸入我們的請求地址和請求方式

查看返回結果

(未完待續)

AngularJs調用Restful實現CRUD - AngularJs

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.