2

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?

Aleyna
  • 1,857
  • 4
  • 20
  • 27
  • Using your debugger, can you see the http request for the view file ? – James Dec 25 '13 at 01:48
  • @James, good point. XHR loads `views/splash.html` only. No request made for `views/home.html` – Aleyna Dec 25 '13 at 01:58
  • works fine here http://plnkr.co/edit/22oe2LpJ0M8XBgw5S1O5?p=preview – charlietfl Dec 25 '13 at 02:03
  • Discard my previous comment plunker works after few chances in my case. Interesting. My real code with some additional module configuration works with AngularJS prior to v1.2.5 – Aleyna Dec 25 '13 at 02:18

0 Answers0