ionic + angularJS $ionicHistory接口文档

$ionicHistory keeps track of views as the user navigates through an app. Similar to the way a browser behaves, an Ionic app is able to keep track of the previous view, the current view, and the forward view (if there is one). However, a typical web browser only keeps track of one history stack in a linear fashion.

Unlike a traditional browser environment, apps and webapps have parallel independent histories, such as with tabs. Should a user navigate few pages deep on one tab, and then switch to a new tab and back, the back button relates not to the previous tab, but to the previous pages visited within that tab.

$ionicHistory facilitates this parallel history architecture.

Methods

viewHistory()

The app's view history data, such as all the views and histories, along with how they are ordered and linked together within the navigation stack.

  • Returns: object Returns an object containing the apps view history data.

currentView()

The app's current view.

  • Returns: object Returns the current view.

currentHistoryId()

The ID of the history stack which is the parent container of the current view.

  • Returns: string Returns the current history ID.

currentTitle([val])

Gets and sets the current view's title.

Param Type Details
val
(optional)
string

The title to update the current view with.

  • Returns: string Returns the current view's title.

backView()

Returns the view that was before the current view in the history stack. If the user navigated from View A to View B, then View A would be the back view, and View B would be the current view.

  • Returns: object Returns the back view.

backTitle()

Gets the back view's title.

  • Returns: string Returns the back view's title.

forwardView()

Returns the view that was in front of the current view in the history stack. A forward view would exist if the user navigated from View A to View B, then navigated back to View A. At this point then View B would be the forward view, and View A would be the current view.

  • Returns: object Returns the forward view.

currentStateName()

Returns the current state name.

  • Returns: string

goBack([backCount])

Navigates the app to the back view, if a back view exists.

Param Type Details
backCount
(optional)
number

Optional negative integer setting how many views to go back. By default it'll go back one view by using the value -1. To go back two views you would use -2. If the number goes farther back than the number of views in the current history's stack then it'll go to the first view in the current history's stack. If the number is zero or greater then it'll do nothing. It also does not cross history stacks, meaning it can only go as far back as the current history.

clearHistory()

Clears out the app's entire history, except for the current view.

clearCache()

Removes all cached views within every ionNavView. This both removes the view element from the DOM, and destroy it's scope.

  • Returns: promise

nextViewOptions()

Sets options for the next view. This method can be useful to override certain view/transition defaults right before a view transition happens. For example, the menuClose directive uses this method internally to ensure an animated view transition does not happen when a side menu is open, and also sets the next view as the root of its history stack. After the transition these options are set back to null.

Available options:

  • disableAnimate: Do not animate the next transition.
  • disableBack: The next view should forget its back view, and set it to null.
  • historyRoot: The next view should become the root view in its history stack.
$ionicHistory.nextViewOptions({
  disableAnimate: true,
  disableBack: true
});
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值