This section focuses on how ANGULARJS calls restful and implements data crud.
The main technology used:
Backend: ASP. WebApi + SQLServer2008
Front End: ANGULARJS,BOOTSTRAP3
The main development tools used
Back end: VisualStudio2013 + SQLServer2008
Front End: WEBSTORM8
1. Create a back-end project angularjs_webapi1.1 Create an empty solution name Angularjs_webapi
1.2 Creating a Angularjs_webapi_server service-side project
1.3 Select an empty WEBAPI project and create
1.4 New Controller TestController Class (for testing)
1.5 Writing TestController.cs Implementation code
Using System.Net.Http;Using System.Web.Http;Namespace angularjs_webapi_server.controllers{ PublicClass Testcontroller:apicontroller{ Public Httpresponsemessage Get () { ReturnNew Httpresponsemessage () { Content =New Stringcontent ("I was requested by get ") }; } Public Httpresponsemessage Post () { ReturnNew Httpresponsemessage () { Content =New Stringcontent ("I was requested by post ") }; } public Httpresponsemessage Put () { Span class= "indent" > return new httpresponsemessage () { Content = new stringcontent ( I was requested by put ") }; }}} /span>
1.6 Test The service you just posted with Chrome app Rest Console (if it's not available to download in the store)
To test a GET request http://localhost:31194/api/test
Please enter our request address and request method
View returned results
test the POST request http://localhost:31194/api/test
Please enter our request address and request method
View returned results
Test put request http://localhost:31194/api/test
Please enter our request address and request method
View returned results
(not to be continued)
AngularJs calls restful implementations Crud-angularjs