离子离子导航视图不起作用

时间:2015-02-25 04:03:34

标签: angularjs ionic

我是离子的新手,只是想开始使用教程。导航到http://localhost:8100/#/home时,我的home.html文件无法显示。没有错误。我错过了什么?谢谢!

的index.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">    
        <script src="lib/ionic/js/ionic.bundle.js"></script>
        <script src="cordova.js"></script>    
        <script src="app/app.js"></script>

      </head>

      <body ng-app="scmAPP">
        <ion-nav-view></ion-nav-view>
      </body>

    </html>

Home.html中

<ion-nav-bar class="bar-balanced">
    <h1 class="title">SCM Home</h1>
</ion-nav-bar>


<ion-tabs class="tabs-icon-top">

    <ion-tab title="Profile" icon="icon-home" href="#">
        <ion-view></ion-view>
    </ion-tab>

    <ion-tab title="Selfies" icon="icon-home" href="#">
        <ion-view></ion-view>
    </ion-tab>  

</ion-tabs>

app.js

    angular.module('scmAPP', ['ionic'])

    .run(function ($ionicPlatform) {
      $ionicPlatform.ready(function () {
        if (window.StatusBar) {
          StatusBar.styleDefault();
        }
      });
    })

    .config(function($stateProvider, $urlRouterProvider){

        $stateProvider

            .state('home', {
                url: "/home",
                templateURL: "app/home/home.html"
            });

        $urlRouterProvider.otherwise("/home");

    });

1 个答案:

答案 0 :(得分:3)

查看您的家庭HTML,您似乎想要一个标签式应用。 为此,您需要一个抽象状态,其中包含&#34;标签栏/菜单&#34;。

查看标签主项目。

ionic start testFolder tabs

这将为您提供一个良好的项目设置。

详细地说,您肯定需要像

这样的抽象状态
    .state('tab', {
        url: "/tab",
        abstract: true,
        templateUrl: "templates/tabs.html"
      })

相应的tabs.html

&#13;
&#13;
<!--
Create tabs with an icon and label, using the tabs-positive style.
Each tab's child <ion-nav-view> directive will have its own
navigation history that also transitions its views in and out.
-->
<ion-tabs class="tabs-icon-top tabs-color-active-positive">


  <!-- Dashboard Tab -->
  <ion-tab title="Status" icon-off="ion-ios7-pulse" icon-on="ion-ios7-pulse-strong" href="#/tab/dash">
    <ion-nav-view name="tab-dash"></ion-nav-view>
  </ion-tab>


  <!-- Chats Tab -->
  <ion-tab title="Chats" icon-off="ion-ios7-chatboxes-outline" icon-on="ion-ios7-chatboxes" href="#/tab/chats">
    <ion-nav-view name="tab-chats"></ion-nav-view>
  </ion-tab>

  <!-- Friends Tab -->
  <ion-tab title="Friends" icon-off="ion-ios7-heart-outline" icon-on="ion-ios7-heart" href="#/tab/friends">
    <ion-nav-view name="tab-friends"></ion-nav-view>
  </ion-tab>


  <!-- Account Tab -->
  <ion-tab title="Account" icon-off="ion-ios7-gear-outline" icon-on="ion-ios7-gear" href="#/tab/account">
    <ion-nav-view name="tab-account"></ion-nav-view>
  </ion-tab>


</ion-tabs>
&#13;
&#13;
&#13;