Ionic Framework从一个页面导航到另一个页面

时间:2016-01-08 07:17:18

标签: android ionic-framework

我正在离子框架中开发android应用程序。任何人都可以指导我如何从一个页面重定向到另一个页面。

这是我的代码

的index.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
-->

<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>

<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>

<!-- your app's js -->
<script src="js/app.js"></script>
<script src="js/controller.js"></script>

</head>
<body ng-app="starter">

    <ion-pane>

    <div class="item" align="center">
        Current Seminars
    </div>

    <ion-content  scroll="true" overflow-scroll="true" class="iframe-wrapper">
    <iframe class= 'webPage' data-tap-disabled="true" name= "eventsPage" src="http://www.google.com">
    </iframe>

</ion-content>

<div class="bar bar-footer bar-positive">
    <div class="title" align="center" >Next</div>

</div>
</ion-pane>

</body>
</html>

app.js

// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
var app=angular.module('starter', ['ionic'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
  cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

      // Don't remove this line unless you know what you are doing. It stops the viewport
      // from snapping when text inputs are focused. Ionic handles this internally for
      // a much nicer keyboard experience.
      cordova.plugins.Keyboard.disableScroll(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
});

当用户点击“下一步”时,我想在下一页重定向他/她。谢谢。

1 个答案:

答案 0 :(得分:1)

您可以将一个页面重定向到另一个页面:

<强> 应用程序/ index.html的

<html ng-app="starter">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <link href="http://code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
    <script src="http://code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
 <script>
     angular.module('starter', ['ionic'])
     .config(function($stateProvider, $urlRouterProvider) {
         $stateProvider
         .state('home', {
              url: "/home",
              templateUrl: "templates/home.html",
              controller: "HomeCtrl"
        })
        .state('detail', {
              url: "/detail",
              templateUrl: "templates/detail.html",
              controller: "DetailCtrl"
         })    
       $urlRouterProvider.otherwise("/home");
     })
     .controller('HomeCtrl', function($scope) { 
     })
     .controller('DetailCtrl', function($scope) {  
     })
 </script>
 </head>
 <body>
    <ion-nav-bar></ion-nav-bar>
    <ion-nav-view></ion-nav-view>
 </body>
 </html>

<强> 应用程序/模板/ home.html做为

<ion-view view-title="Home">
    <ion-content class="padding">
      <a ui-sref="detail">Next Page</a>          
    </ion-content>
</ion-view>

<强> 应用程序/模板/ detail.html

<ion-view view-title="Detail">
    <ion-content class="padding">
      <p>Detail</p>         
    </ion-content>
</ion-view>