ngRoute
The
ngRoute
module provides routing and deeplinking services and directives for angular apps.
Module Components
Property | Type | Description |
---|
ngView | Directive | ngView is a directive that complements the $route service by including the rendered template of the current route into the main layout (index.html) file. Every time the current route changes, the included view changes with it according to the configuration of the $route service. |
$routeProvider | Provider | Used for configuring routes. |
$route | Service | $route is used for deep-linking URLs to controllers and views (HTML partials). It watches $location.url() and tries to map the path to an existing route definition. |
$routeParams | Service | The $routeParams service allows you to retrieve the current set of route parameters. |
ng-template | Directive | The directive is used to create an html view using script tag. It contains "id" attribute which is used by $routeProvider to map a view with a controller. |
ng-template
Example
Define a script block with type as
ng-template
within the main module.
snippet
<div ng-app = "mainApp">
...
<script type = "text/ng-template" id = "addStudent.htm">
<h2> Add Student </h2>
{{message}}
</script>
</div>