I have seen many different questions that look alike mine but my question is different. I have the following routes set up.
myModule.config(function($routeProvider) {
$routeProvider.
when('/', {templateUrl: 'views/splash.html', controller: SplashCtrl}).
when('/home', {templateUrl: 'views/home.html', controller: HomeCtrl});
});
and the controllers as follows:
function SplashCtrl($scope, $location, $timeout) {
$timeout(function() {
console.log('going home');
$location.url('/home'); //tried $location.path('/home') as well
}, 1000);
}
function HomeCtrl($scope) {
console.log('in HomeCtrl');
}
I got the following on my console:
going home at js/main.js:2475
in HomeCtrl at js/main.js:2494
Looks like the HomeCtrl gets loaded but the problem is that views/home.html
is never shown on the screen. The view never changes yet the controller does. Any ideas what may be wrong with the code above?
More context: I am working on a Cordova + AngularJS app. The code above is tested on Android 4.2.3 stock chromium web view.
Edit 1: Now tested on Chrome v31.0.1650
it does not work on desktop as well. I wonder if this is a known bug attached to AngularJS v1.2.6
.
Edit 2: Downgrading AngularJS to v1.2.4 or prior solves the problem. Apparently, there is something to do with AngularJS and the code above seems just fine?