Adding & Declaring a
Dependency on Route Module
·
Added an Angular Route Module
·
Declaring a Dependency of Angular Route Module
Added an Angular Route ModuleIn the above example we have added an angular route module in head section and it must be added in the angular application i.e.
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular-route.min.js"></script>
Declaring a Dependency of Angular Route Module
In the above example, we have declared an angular dependency module on application route called ngRoute i.e.
var app = angular.module("routesApp", ['ngRoute']);
The ngView/ ng-View Directive
The ngView/ng-view is a directive and its use to allow us to setup the angular routes.
The ngView/ng-view is a directive and its use to allow us to setup the angular routes.
The ngView directive has the
following features.
1.
All the View will update, when events ($routeChangeStart, $routeChangeSuccess,$routeChangeError, $routeUpdate)
are fired.
2.
It provides the Link between controllers to scope when routes are
specified.
3.
It provides the link between the new scopes to the new templates.
In the above example we used ngView/ng-view directive
i.e.<div ng-view></div>
Inside the HTML div, ng-view renders the HTML template of the current given route. When the given current route changed that HTML template will also change.
Blogger Comment
Facebook Comment