ionic $ scope.go不在设备上工作

时间:2015-03-15 20:20:45

标签: android cordova angular-ui-router ionic-framework ionic

使用空白模板在最新离子上配置了一个新项目

$ state.go(' post.request&#39);在LoginCtrl中工作在浏览器但不是我在手机上运行(S4 android 5.0)

检查了logcat是否有任何错误但是干净了。

这是模板

<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>

控制器

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

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

和app文件

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');
    });

1 个答案:

答案 0 :(得分:4)

您的模板网址必须是相对的:

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

此处说明:

Using Angular UI-Router with Phonegap