var app = angular.module("app", ["ngRoute"]);
app.config(function ($routeProvider) {
$routeProvider
.when('/', {
// file:///C:/Users/Answer1215/WebstormProjects/angular/angular_config/index.html#/
template: "Yum!!"
})
.when('/pizza', { This shoule be in front of /:message
// file:///C:/Users/Answer1215/WebstormProjects/angular/angular_config/index.html#/pizza
template: "Welcome to my country"
})
.when('/:message', {
// file:///C:/Users/Answer1215/WebstormProjects/angular/angular_config/index.html#/hollo
template: "{{model.message}}",
controller: "AppCtrl"
}).when('/:country/:state/:city', {
//file:///C:/Users/Answer1215/WebstormProjects/angular/angular_config/index.html#/china/shanghai/pudong
template: "{{country.message}}",
controller: "AppCtrl"
})
.when('/:country/:state/:city/:err', {
// file:///C:/Users/Answer1215/WebstormProjects/angular/angular_config/index.html#/china/shanghai/pudong/dezhou?zoom=3
redirectTo: function (routeParams, path, search) {
console.log(routeParams);
console.log(path); ///china/shanghai/pudong/dezhou
console.log(search); //{zoom: 3}
// If meet stuitaions which not quite understand, send it back to the location you want
return "/" + routeParams.country + "/" + routeParams.state + "/" + routeParams.city;
}
})
.otherwise({
redirectTo: "/"
});
})
;
app.controller("AppCtrl", function ($scope, $routeParams) {
$scope.model = {
message: $routeParams.message
}
$scope.country = {
message: $routeParams.country + ", " +
$routeParams.state + ", " +
$routeParams.city
}
});