AngularJS ng-click to go to another page (with Ionic framework)

后端 未结 5 1539
暗喜
暗喜 2020-12-13 04:03

Ideally, when I click on the button (which is in the Ionic navbar at the top), it should bring me to another page. However its not working. Upon click, the nav bar buttons a

5条回答
  •  鱼传尺愫
    2020-12-13 04:57

    One think you should change is the call $state.go(). As described here:

    • $state.go(to [, toParams] [, options])

    The param passed should be the state name

    $scope.create = function() {
      // instead of this
      //$state.go("/tab/newpost"); 
    
      // we should use this
      $state.go("tab.newpost"); 
    };
    

    Some cite from doc (the first parameter to of the [$state.go(to \[, toParams\] \[, options\]):

    to

    String Absolute State Name or Relative State Path

    The name of the state that will be transitioned to or a relative state path. If the path starts with ^ or . then it is relative, otherwise it is absolute.

    Some examples:

    $state.go('contact.detail') will go to the 'contact.detail' state
    $state.go('^') will go to a parent state.
    $state.go('^.sibling') will go to a sibling state.
    $state.go('.child.grandchild') will go to a grandchild state.
    

提交回复
热议问题