Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/453.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 离子变化位置赢了';行不通_Javascript_Angularjs_Ionic Framework - Fatal编程技术网

Javascript 离子变化位置赢了';行不通

Javascript 离子变化位置赢了';行不通,javascript,angularjs,ionic-framework,Javascript,Angularjs,Ionic Framework,我在爱奥尼亚是新来的(只是在angularjs方面少了一点) 我尝试在两个视图之间进行简单切换: HTML <body ng-app="starter" animation="slide-left-right-ios7"> <!-- The nav bar that will be updated as we navigate between views. --> <ion-nav-bar class="bar-stable n

我在爱奥尼亚是新来的(只是在angularjs方面少了一点)

我尝试在两个视图之间进行简单切换:

HTML

<body ng-app="starter" animation="slide-left-right-ios7">
    <!-- 
      The nav bar that will be updated as we navigate between views.
    -->
    <ion-nav-bar class="bar-stable nav-title-slide-ios7">
      <ion-nav-back-button class="button-icon icon  ion-ios7-arrow-back">
        Back
      </ion-nav-back-button>
    </ion-nav-bar>

    <ion-nav-view name="intro"></ion-nav-view>
    <ion-nav-view name="login"></ion-nav-view>
    <ion-nav-view name="home"></ion-nav-view>
    <ion-nav-view name="pizze"></ion-nav-view>
    <ion-nav-view name="sponsor"></ion-nav-view>
    <ion-nav-view name="scontrino"></ion-nav-view>
  </body>
Controllers.js

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

  // Ionic uses AngularUI Router which uses the concept of states
  // Learn more here: https://github.com/angular-ui/ui-router
  // Set up the various states which the app can be in.
  // Each state's controller can be found in controllers.js
  $stateProvider


    .state('intro', {
      url: '/intro',
      views: {
        'intro': {
          templateUrl: 'templates/intro.html',
          controller: 'IntroCtrl'
        }
      }
    })
    .state('login', {
      url: '/login',
      views: {
        'login': {
          templateUrl: 'templates/login.html',
          controller: 'LoginCtrl'
        }
      }
    })
  $urlRouterProvider.otherwise('/intro');

});
angular.module('starter.controllers', [])

.controller('IntroCtrl', function($scope,$location) {
    $location.url("/login");

})
.controller('LoginCtrl', function($scope,$location) {

})
简介显示正确,但当它试图将位置更改为“login.html”时,会显示:

有什么问题吗

谢谢

试试这个

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

.controller('IntroCtrl', function($scope,$state) {
     $state.transitionTo("login");

})
.controller('LoginCtrl', function($scope,$location) {

})

您使用的视图名称错误。 在状态中,视图的名称

views: {
  '_name_': {
}
用于不同视图的不同导航历史记录

假设您有两个选项卡,
home
pizza
,并且您希望这两个选项卡都有多个页面,那么视图名称就很方便了

对于您的示例,了解您希望如何使用视图是很重要的。 我为您设置了一个示例,使视图可以在选项卡中访问。 有关该示例,请参见此处:

views: {
  '_name_': {
}