iamxxy 发表于 2015-11-21 12:34:09

纠结,关于页面跳转的问题

index.html的主要代码如下
<body ng-app="start" >
                <ion-view>
                       
                        <p>
                       
                        <ion-spinner icon="bubbles" class="spinner-balanced"></ion-spinner>

                </p>
               
                       
                </ion-view>



        </body>

对应的app.js代码如下
angular.module('start', ['ionic','controllers'])
.run(function($ionicPlatform,$state,$state) {
        $ionicPlatform.ready(function() {
                // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
                // for form inputs)
                if (window.cordova && window.cordova.plugins.Keyboard) {
                        cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
                }
                if (window.StatusBar) {
                        StatusBar.styleDefault();
                }       
        });

})
.config(function($stateProvider, $urlRouterProvider) {
   $urlRouterProvider.when("", "/activate");
$stateProvider
.state('activate', {
        url:'/activate',
    templateUrl: 'templates/activate.html',
    controller: 'Activate'
   
})
.state('lock', {
        url:'/lock',
       
    templateUrl: 'templates/gusturelockPage.html',
    controller: 'Lock'
})
.state('main', {
        url:'/main',
       
    templateUrl: 'templates/mainpage.html',
    controller: 'UserInfo'
});
// if none of the above states are matched, use this as the fallback
// $urlRouterProvider.otherwise('/activate');
});

其中controllers是另外在一个controllers.js里面声明的控制器模块,angular.module('start', ['ionic','controllers'])把它也包进来了。
上面用到的要跳转的html都放在了一个新建的template文件夹当中。
新人求问,为什么index.html打开运行之后不跳转到activate对应的html呢?

admin 发表于 2015-11-21 16:56:33

controller里面写对应的跳转state.go()实现跳转

torral 发表于 2015-11-21 22:23:58

如果楼主现在没有什么头绪建议看看ionic的列子,连接如下
http://codepen.io/ionic/pen/6d3f67226cbecc8383cc8680b6d3832a
你也可以从官网进

iamxxy 发表于 2015-11-22 11:36:16

admin 发表于 2015-11-21 16:56
controller里面写对应的跳转state.go()实现跳转

你好,我加了$state.go之后,发现url的确是有改变了,由原来的/www/index.html变成了/www/index.html#/activate,但是页面也没有什么改变。请问这个#/是什么意思,是不是路由的url配错了?

iamxxy 发表于 2015-11-22 12:46:37

噢,找到问题了,index中不能用<ion-view>而是要用<ion-nav-view>.感谢回答的各位

iamxxy 发表于 2015-11-22 12:46:57

噢,找到问题了,index中不能用<ion-view>而是要用<ion-nav-view>.感谢回答的各位
页: [1]
查看完整版本: 纠结,关于页面跳转的问题