Exploring Main.js
$routeProvider
.when('/home', {
templateUrl: 'home.html',
controller: 'StudentController'
})
.when('/viewStudents', {
templateUrl: 'viewStudents.html',
controller: 'StudentController'
})
.when('/viewTeacher', {
templateUrl: 'viewTeacher.html',
controller: 'StudentController'
})
.otherwise({
redirectTo: '/home'
});
Code within another JavaScript file
$rootScope.$on("$routeChangeStart", function(event, next, current){
console.log(event);
//detecting action here
});
When a user visits index.html, the home route is triggered from JS and home.html is added to the view
.otherwise({
redirectTo: '/home'
});
There is a button that calls viewStudents.html, then the route changes and viewStudents.html is rendered
How can I determine in the routeChangeStart function whether the route change was initiated by JavaScript or by a click from the user?