Configuring the $routeProvider :-
In the above example, we have
configured the $routeProvider. The $routeProvider is
used to create the$route services. The $routeProvider is
used to manage the application routes and it’s responsible for updating views
and communicate with its controllers as well.
The example code as given below
<script type="text/javascript"> var app = angular.module("routesApp", ['ngRoute']); app.config(['$routeProvider', function ($routeProvider) { $routeProvider.when('/routeURL1', { templateUrl: 'templateURL1', controller: 'routesController' }). when('/routeURL2', { templateUrl: 'templateURL2', controller: 'routesController' }). when('/routeURL3', { templateUrl: 'templateURL3', controller: 'routesController' }). otherwise({ redirectTo: '/login' }); } ]); </script>
Here $routeProvider is
used to configured the config () module and passed the $routeProvider as
parameter in the config () function.
The $routeProvider is
configured with the help of the functions when () and otherwise
().
The when () function take
the route URL, template URL and its controllers also.
The otherwise () function
take the redirect URL if not exist in the when () functions.
Blogger Comment
Facebook Comment