我想在带有多个页面的离子中创建一个应用程序,但我无法将其他页面链接到按钮



我正在尝试制作类似的东西[plunker] [1]>

但是,当我在我的离子应用程序中尝试此确切的代码时,我在屏幕上什么也没有。我已经问了这个问题,但是没有人能帮助我。

如果您知道其他替代方案或一些教程或链接,请发布它。

请注意,我正好将我的离子项目代码复制到Plunker中,以便您可以更好地理解它,但它可能在Plunker中不起作用。

如果可以的话,请帮助我。

<[MY Plunker][2]>


  [1]: http://plnkr.co/edit/H5n7SM?p=preview
  [2]: https://plnkr.co/edit/fJTaer?p=preview

index.html

<!DOCTYPE html>
<html data-ng-app="starter">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>
    <link rel="manifest" href="manifest.json">
    <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">
    -->
    <script src="cordova.js"></script>
    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>
   <script src="js/angular-ui-router.min.js"></script>
    <!-- cordova script (this will be a 404 during development) -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ng-cordova/0.1.27-alpha/ng-cordova.js"></script>
    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/homeController.js"></script>
    <script src="js/secondController.js"></script>
  </head>
  <body>
    <ion-pane>
        <ion-content>
            <div id="wrapper" ui-view></div>
        </ion-content>
    </ion-pane>
  </body>
</html>

app.js

var app = angular.module('starter', ['ionic','ngCordova', 'ui.router'])
app.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);
      }
      ionic.Platform.fullScreen();
      if(window.StatusBar) {
        StatusBar.styleDefault();
      }
  });
})
 app.config(function($stateProvider, $urlRouterProvider){
  $stateProvider
    .state('index', {
      url: "",
          templateUrl: "home.html",
          controller: "homeController"            
    })
    .state('second', {
      url: "/second",
          templateUrl: "second.html",
          controller: "secondController"
    })
});

home.html

<div style="width:100px;height: 50px;background-color: blue">home</div>
<button ui-sref="second">click</button>

second.html

<div style="width:100px;height: 50px;background-color: green">second</div>
<button ui-sref="index">click</button>

homecontroller.js

app.controller('homeController', function($scope,$ionicPlatform,$state) {
});

secondcontroller.js

app.controller('secondController', function($scope,$ionicPlatform,$state) {
});

相关内容

  • 没有找到相关文章

最新更新