Wednesday, March 4, 2015

Ionic Route TemplateUrl Not Found Issue

Note that both of the following are working in browser & simulator, even run directly on the phone is good. However, when you package the app and install it on your phone, the template file will not be found.

This is a tricky one because when the app installed on the phone, unlike web deployment, it most likely is not installed at root of your phone, thus, it cannot find the file.

To solve this, just trying to avoid starting with '/' in your url mapping.

CORRECT

app.config(function($stateProvider, $urlRouterProvider) {

  $stateProvider
  .state('home', {
    url: '/home',
    templateUrl: 'template/list.html'
  });

  $urlRouterProvider.otherwise("/home");
});

WRONG

app.config(function($stateProvider, $urlRouterProvider) {

  $stateProvider
  .state('home', {
    url: '/home',
    templateUrl: '/template/list.html'
  });

  $urlRouterProvider.otherwise("/home");
});




No comments:

Post a Comment