In event function, print the parameters : event, next and current
app.controller("studentController", function ($route, $http, $rootScope, $log) {
$rootScope.$on("$locationChangeStart", function (event, next, current) {
$log.debug("$locationChangeStart triggered...");
$log.debug(event);
$log.debug(next);
$log.debug(current);
})
$rootScope.$on("$routeChangeStart", function (event, next, current) {
$log.debug("$routeChangeStart triggered...");
$log.debug(event);
$log.debug(next);
$log.debug(current);
})
var curr = this;
curr.reloadData = function() {
$route.reload();
}
$http.get("service/api/GetAllStudents").then(
function(response) {
curr.students = response.data;
}
)
});
The data in next and current object for $routeChangeStart and $locationChangeStart are different.
Output
$routeChangeStart triggered...
Object {name: "$routeChangeStart", targetScope: m, defaultPrevented: false, currentScope: m}
Object {params: Object, pathParams: Object, $$route: Object}
Object {params: Object, pathParams: Object, $$route: Object, loadedTemplateUrl: "Templates/students.html", locals: Object...}
$locationChangeStart triggered...
Object {name: "$locationChangeStart", targetScope: m, defaultPrevented: false, currentScope: m}
http://localhost:8080/proj/trainings
http://localhost:8080/proj/students
No comments:
Post a Comment
Note: only a member of this blog may post a comment.