- The AngularJS Supports Single Page Application (SPA) which shows multiple view templates on a single page.
- We can use the ngRoute module for navigate the multiple pages without reload the page.
- To use routing we should include AngularJS "angular-route.js" JavaScript source file from googleapis.com.
- The following supports are given by AngularJS for routing
- ngRoute Module.
- ng-view Directive.
- $routeProvider Provider.
- ng-template Directive.
Syntax for ngRoute Module in AngularJS:
Sample code for Routing in AngularJS:
tutorials.html template:
html.html template:
css.html template:
php.html template:
HTML:
- Viewable HTML contents in AngularJS Application.
Routing :
- Routing configuration of Application Module.
Code Explanation for Routing in AngularJS:
- To use AngularJS Routing we should include "angular-route.js" JavaScript source file from googleapis.com.
- The set of navigation links are specified in <a> tag for different templates with different external files.
- The ng-view directory is used to show the rendered template in the Current Application.
- The angular.module used to create an Application module for “myApp” module.
- The “ngRoute” is used to specify the dependency of routing in the application module.
- The config is used to configure the application with $routeprovider.
- The .when used to specify when the templateUrl routed to the view.
- The set of templateUrl for $routeProvider for the navigation links.
Sample Output for Animation in AngularJS:
- On page load by default “tutorials.html” page is routed.
- When user click the HTML link then “html.html” page is routed. And the URL changed to #/html.
- When user click the CSS link then “css.html” page is routed. And the URL changed to #/css.
- When user click the PHP link then “php.html” page is routed. And the URL changed to #/php.
Related Searches to angularjs routing
angular route cdn
angular routeprovider
@angular/router npm
ngroute vs ui router
angularjs stateprovider
angularjs route example
angularjs ngroute
angularjs routeprovider
angularjs routing example with parameters
what is angularjs
angularjs tutorial
ngroute example
angularjs tutorials