I am new to AngularJS and need some advice on how to structure a SPA with Web API for an internal order entry system (SEO not a concern). I would like to set this up in a clean, well-structured fashion for efficient development, debug & deployment.
Here is what I am planning to do:
As an alternative, I guess I could use one Visual Studio solution for the full site (both SPA and WebAPI) and then use razor to serve the html files (or figure out how to disable the default MVC plumbing and serve straight HTML instead, to avoid the MVC overhead). Also, would I then have to put both the SPA and the WebAPI in the same project to be able to debug with Visual Studio easily?
Or perhaps there is a better approach?
Advice on best practices / good approaches on this would be appreciated.
Using AngularJS in ASP.NETAfter selecting Web, select ASP.NET Web Application (. NET Framework) under The Web. We need to give the project name in name column, which looks, as shown below. Project template Window will open after clicking OK button.
Open Visual Studio >> File >> New >> Project >> Select Web Application. After that click OK and you will see the templates. Select the Web API template. Click OK.
Answer: Yes. All the sites created with Angular are SPAs. AngularJS is defined in the SPA framework.
We have created a two different projects under the same solution , First one is the empty web application and the next one is a class library .
1) Web application project consists of angular JS and the other client side components .
2) Class library consists of the Web api controllers and the relevant components such as filters and the other details.
We have a bootstrap class in the class library project which bootstraps the webapi and the container for us. Also it makes the testing of Web api easily
public class Bootstrap
{
public void ConfigureRoute(HttpConfiguration httpConfiguration)
{
}
public BootStrapApplication ConfigureContainer()
{
}
}
From the global.asax in the app_start we call the BootStrap application class and the method .
For application structure on angularjs i found the John papa guide efficient https://github.com/johnpapa/angularjs-styleguide
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With