A single-page application (SPA), also known as single-page interface (SPI), is a web application or web site that fits on a single web page with the goal of providing a more fluid user experience akin to a desktop application.
And developing SPA has been so easier with AngularJS Route Service .
Application routes in Angular are declared via the $routeProvider, which is the provider of the $route service. This service makes it easy to wire together controllers, view templates, and the current URL location in the browser. Using this feature we can implement deep linking, which lets us utilize the browser’s history (back and forward navigation) and bookmarks.
I am gonna show how to build simple SPA within 1 hour 🙂
Here is my index.html Code ::: (ASP.Net developers can think this index.html as MasterPage)
The $route service is usually used in conjunction with the ngView directive. The role of the ngView directive is to include the view template for the current route into the layout template, which makes it a perfect fit for our index.html template.
(This ngView directive can be compared as Main ContentPlaceHolder of ASP.Net , just saying for .Net Devs )
My app.js code is like below :::
In this RouteProvider we can define URL and HTML Template .
And For this App , I have 3 Partial Views . The codes of these views are like below :::
So Here , you are done with the simple SPA Site 🙂
The Site will look like – >
To Read Part 2 -> Please Click AngularJS Routing : Part 2 – make # (Hash) invisible from URL in SPA