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 the backend Project ANGULARJS_WEBAPI 1.1 to establish the 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
usingSystem.Net.Http;usingSystem.Web.Http;namespaceangularjs_webapi_server.controllers{ Public classTestcontroller:apicontroller { Publichttpresponsemessage Get () {return NewHttpresponsemessage () {Content=NewStringcontent ("I'm requesting it through get.") }; } Publichttpresponsemessage Post () {return NewHttpresponsemessage () {Content=NewStringcontent ("I'm requesting it via post.") }; } Publichttpresponsemessage Put () {return NewHttpresponsemessage () {Content=NewStringcontent ("I asked for it through put.") }; } }}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)