0

我有我正在尝试在 IONIC 中学习抽象路线。但是我的代码有问题。路线上有错误,但项目结构。有人知道检查吗?

我的文件 ROUTES.JS

angular.module('starter')
    .config(function($stateProvider, $urlRouterProvider){

    $urlRouterProvider.otherwise("/menu/listagem");
    $stateProvider


    .state("menu",{
        url:"/menu",
        templateUrl:'templates/menu.html',
        abstract:true,
        controller:'listagemController'
    })

     .state("menu.listagem", {
        url: '/listagem', 
        views:{
            'menuContent':{
                templateUrl:'templates/listagem.html'
            }
        }

     });ngular.module('starter')
    .config(function($stateProvider, $urlRouterProvider){

    $urlRouterProvider.otherwise("/menu/listagem");
    $stateProvider


    .state("menu",{
        url:"/menu",
        templateUrl:'templates/menu.html',
        abstract:true,
        controller:'listagemController'
    })

     .state("menu.listagem", {
        url: '/listagem', 
        views:{
            'menuContent':{
                templateUrl:'templates/listagem.html'
            }
        }

     });

我的文件 menu.html

<ion-side-menus enable-menu-with-back-views="true">

    <ion-side-menu-content>

        <ion-nav-bar class="bar-positive">
            <ion-nav-back-button>
            </ion-nav-back-button>

            <ion-nav-buttons side="left">
                <button class="button button-clear button-icon light ion-navicon" menu-toggle="left"></button>
            </ion-nav-buttons>
        </ion-nav-bar>

        <ion-nav-view name="menuContent"></ion-nav-view>
    </ion-side-menu-content>

    <ion-side-menu side="left">

    <ion-header-bar class="bar-positive">
        <h1 class="title">Menu</h1>
    </ion-header-bar>

        <ion-content>

        <ion-list>
            <ion-item href="#/menu/home" menu-close>Home</ion-item>
            <ion-item href="#/menu/login" menu-close>Login</ion-item>
            <ion-item href="" menu-close>Sair</ion-item>
        </ion-list>

        </ion-content>

    </ion-side-menu>

</ion-side-menus>

我的文件 listagem.html

   <ion-view>

<ion-nav-title>Plantas Medicinais</ion-nav-title>

<ion-content>

<h1="title">SUCESS</h1>


</ion-content>  

</ion-view>
4

1 回答 1

0

在 ROUTE.JS 中试试这个

angular.module('starter', ['ionic'])
.config(function($stateProvider, $urlRouterProvider,$httpProvider) {

   $httpProvider.defaults.headers.common = {};
  $httpProvider.defaults.headers.post = {};
  $httpProvider.defaults.headers.put = {};
  $httpProvider.defaults.headers.patch = {};
  $stateProvider
    .state('menu', {
      url: "/menu",
      abstract: true,
      templateUrl: "templates/menu.html",
      controller: 'listagemController'
    })

    .state('menu.listagem', {
      url: "/listagem",
      views: {
        'menuContent' :{
          templateUrl: "templates/listagem.html"
        }
      }
    })

  $urlRouterProvider.otherwise('/menu/listagem');
});

In MENU.HTML write 

<ion-side-menus>
  <ion-side-menu-content>
    <ion-nav-bar class="bar-light nav-title-slide-ios7">
      <ion-nav-back-button class="button-clear"><i class="icon ion-ios7-arrow-back"></i> Back</ion-nav-back-button>
    </ion-nav-bar>
    <ion-nav-view name="menuContent" animation="slide-left-right"></ion-nav-view>
  </ion-side-menu-content>
  <ion-side-menu side="left">   
    <ion-content class="gem-sidebar dark">
        <ion-list>
            <ion-item href="#/menu/home" menu-close>Home</ion-item>
            <ion-item href="#/menu/login" menu-close>Login</ion-item>
            <ion-item href="" menu-close>Sair</ion-item>
        </ion-list>          
    </ion-content>
  </ion-side-menu>
</ion-side-menus>
于 2016-09-06T05:17:48.417 回答