0

Have configured a new project on latest ionic with blank template

$state.go('post.request'); in LoginCtrl is working in browser but not when I run on phone (S4 android 5.0)

Have checked logcat for any errors but its clean.

This is the template

<div class="bar bar-header bar-assertive">
  <h1 class="title">HRC Karaoke</h1>
</div>

<div class="list padding has-header">
    <button class="button button-stable fullwidth" ng-click="checkLogin();">
      Login with Facebook
    </button>
</div>

the controller

angular.module('hrc.controllers', [])

    .controller('LoginCtrl', function ($scope, $state) {
        $scope.checkLogin = function () {
            $state.go('post.request');
        };
    })
    .controller('RequestCtrl', function ($scope) {
        console.log("request");
    });

And app file

angular.module('hrc', ['ionic', 'hrc.controllers', 'ui.router'])
    .run(function ($rootScope, $state) {
    })

    .config(function ($stateProvider, $urlRouterProvider, $stateProvider) {
        $stateProvider
            .state('pre', {
                url: "/pre",
                abstract: true,
                views: {
                    'main': {
                        templateUrl: "t/pre/pre.html",
                        controller: "StartCtrl"
                    }
                }
            })
            .state('pre.login', {
                url: "/login",
                views: {
                    'preContent': {
                        templateUrl: "t/pre/login.html",
                        controller: "LoginCtrl"
                    }
                }
            })
            .state('post', {
                url: "/post",
                abstract: true,
                views: {
                    'main': {
                        templateUrl: "t/post/post.html",
                        controller: "PostCtrl"
                    }
                }
            })
            .state('post.request', {
                url: "/request",
                views: {
                    'postContent': {
                        templateUrl: "/t/post/request.html",
                        controller: "RequestCtrl"
                    }
                }
            })
        $urlRouterProvider.otherwise('/pre/login');
    });
Anuj Kothari
  • 33
  • 1
  • 7

1 Answers1

4

Your template URL must be relative :

"/t/post/request.html" => "t/post/request.html"

Explanation here :

Using Angular UI-Router with Phonegap

Community
  • 1
  • 1
Mabdylon
  • 56
  • 4