角度中的离子模板路由

时间:2015-11-14 12:32:34

标签: javascript angularjs ionic-framework ionic

我正在尝试用这种方式创建一个应用程序,我有一个BLANK IONIC模板和2个基于侧边栏的离子模板。

在BLANK TEMPLATE我使用2个图标。我点击第一个图标,它重定向URL但不重定向页面。和第二个图标一样。在这里,我的代码如何。

的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/controllers.js"></script>
  </head>

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

我的另一个页面是app.js.这就是所有路由的来源:

app.js

angular.module('starter', ['ionic', 'starter.controllers'])

.run(function($ionicPlatform) {
  $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);
      cordova.plugins.Keyboard.disableScroll(true);

    }
    if (window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
  });
})

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

    .state('appa', {
    url: '/appa',
    abstract: true,
    templateUrl: 'homeoptions.html'

  })


    .state('appa.home', {
    url: '/home',
    views: {
      'menuContent': {
        templateUrl: 'homeoptions.html'
      }
    }
  })

  .state('appa.fitness', {
    url: '/fitness',
    views: {
      'menuContent': {
        templateUrl: 'fitness-templates/fitness.html'
      }
    }
  })

  .state('appa.cafe', {
      url: '/cafe',
      views: {
        'menuContent': {
          templateUrl: 'cafe-templates/health.html',
          controller: 'TestCtrol'
        }
      }
    })

  // if none of the above states are matched, use this as the fallback
  $urlRouterProvider.otherwise('/appa/home');
});

我的文件夹结构如下:

enter image description here

为什么我的页面没有导航?我只是使用与指南和示例中的说法相同的程序。

任何想法都会有所帮助。让我们知道您的看法。

谢谢! (提前)

0 个答案:

没有答案