In AngularJS, routing is what allows you to create Single Page Applications.
- AngularJS routes enable you to create different URLs for different content in your application.
- AngularJS routes allow one to show multiple contents depending on which route is chosen.
- A route is specified in the URL after the # sign.
Ex:<body ng-app=”MyAngApp”>
<p><a href=”#/!”>MainPage</a></p>
<a href=”#!SubPage1″>SubPage1</a>
<a href=”#!SubPage2″>SubPage2</a>
<a href=”#!SubPage3″>SubPage3</a>
<div ng-view></div>
<script>
var app = angular.module(“MyAngApp”, [“ngRoute”]);
app.config(function($routeProvider) {
$routeProvider
.when(“/”, {
templateUrl : “MainPage.htm”
})
.when(“/SubPage1”, {
templateUrl : “SubPage1.htm”
})
.when(“/SubPage2”, {
templateUrl : “SubPage2.htm”
})
.when(“/SubPage3”, {
templateUrl : “SubPage3.htm”
});
});
</script>
</body>