The ngRoute module enables your application to function as a Single Page Application.
To navigate between different pages in your application while maintaining the behavior of a Single Page Application (SPA) without full page reloads, you can use the ngRoute
module. It enables routing to different views without refreshing the entire application.
Access “red.htm,” “green.htm,” and “blue.htm.”
<body ng-app=”myApp”> <p><a href=”#/!”>Main</a></p> <a href=”#!red”>Red</a> <a href=”#!green”>Green</a> <a href=”#!blue”>Blue</a> <div ng-view></div> <script> var app = angular.module(“myApp”, [“ngRoute”]); app.config(function($routeProvider) { $routeProvider .when(“/”, { templateUrl : “main.htm” }) .when(“/red”, { templateUrl : “red.htm” }) .when(“/green”, { templateUrl : “green.htm” }) .when(“/blue”, { templateUrl : “blue.htm” }); }); </script> </body> |