Use otherwise function of $routeProvider object to provide a default route.
JS
var app = angular.module("module1", ["ngRoute"]);
app.config( function ($routeProvider) {
$routeProvider
.when("/home", {
templateUrl: "templates/home.html",
controller: "homeController"
})
.when("/trainings", {
templateUrl: "templates/trainings.html",
controller: "trainingController"
})
.when("/students", {
templateUrl: "templates/students.html",
controller: "studentController"
})
.when("/contact", {
template : '<h1>Contact Template loaded</h1>'
})
.otherwise( {
redirectTo: '/home'
}) });
- When /home is called, it will include home.html at <ng-view> place.
- When /XYZ is called, it goes to otherwise condition and redirect to route /home (Still includes home.html)
No comments:
Post a Comment
Note: only a member of this blog may post a comment.