首页 文章

Ionic不改变视图/状态,除非它是一个标签

提问于
浏览
0

我的Ionic应用程序中有一个标签栏系统 . 但是,我希望有一些视图不是标签栏的一部分,只是一个按钮打开的页面..出于某种原因,只要页面不是标签页,它就不会打开视图 . 我可以看到URL更改但它不会更改为该视图,除非该视图也是一个选项卡 . 希望这是有道理的 . 我最初是尝试使用Href切换页面,但后来决定在href不工作时尝试ng-click ..这是我的代码如下..

我在哪里定义了州:

.state('tab.friendsadd', {
        url: "/friendsadd",
         templateUrl: "templates/friends-add.html"

})

这是我调用该函数的按钮:

<button class="button button-clear button-assertive" ng-       click="changeview()">New Group</button>

然后这是我的changeview()函数,我知道这个函数被正确调用,因为语句是打印的:

$scope.changeview = function() {
  console.log("hey why isnt this working");
  $state.go("tab.friendsadd"); //change state

}

不确定这可能是问题,但这里是我试图打开的新视图的模板:

<script id="templates/friends-add.html" type="text/ng-template">
      <ion-view view-title="Sign-In">
        <ion-content>
          <p> Header </p>
    <p> Tom brady </p>

        </ion-content>
      </ion-view>
    </script>

谢谢你的帮助 . 我希望这是一个简单的解决方案......

1 回答

  • 0

    尝试

    .state('friendsadd', {
            url: "/friendsadd",
            templateUrl: "templates/friends-add.html"
    })
    

    这在html中

    <button class="button button-clear button-assertive" href="#/friendsadd" ui-sref="friendsadd">New Group</button>
    

    如果您的模板是实际文件,那么您不需要 <script></script> 标签

    如果这不能解决,或者即使它会解决,请为您的路线添加一些调试https://stackoverflow.com/a/28750792/4050230

    希望这可以帮助..

相关问题