本文整理匯總了TypeScript中@angular/common.LocationStrategy.onPopState方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript LocationStrategy.onPopState方法的具體用法?TypeScript LocationStrategy.onPopState怎麽用?TypeScript LocationStrategy.onPopState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@angular/common.LocationStrategy
的用法示例。
在下文中一共展示了LocationStrategy.onPopState方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: constructor
// I initialize the retro-location service. This provides an API that is
// reminiscent of the AngularJS 1.x $location service.
constructor( locationStrategy: LocationStrategy ) {
this.locationStrategy = locationStrategy;
this.popStateEvents = new Subject();
// When the underlying location implementation emits a PopStateEvent, we
// want to communicate that out to any clients that may be subscribed to the
// RetroLocation events.
this.locationStrategy.onPopState(
( event: PopStateEvent | HashChangeEvent ) : void => {
// Since RetroLocation will emit this event when the location is
// changed programmatically, we want to limit it to a single event-type,
// popstate, in order to make things a bit more predictable.
if ( event.type === "popstate" ) {
this.popStateEvents.next({
url: this.url(),
pop: true,
type: "popstate"
});
}
}
);
}
示例2: constructor
constructor(public platformStrategy: LocationStrategy) {
super({ path: _path(platformStrategy), type: 'push' });
platformStrategy.onPopState(event => this._update('pop'));
this._baseHref = _getBaseHref(platformStrategy);
}
示例3: constructor
constructor(public platformStrategy: LocationStrategy) {
super(1);
platformStrategy.onPopState(event => this._update('pop'));
const browserBaseHref = this.platformStrategy.getBaseHref();
this._baseHref = stripTrailingSlash(stripIndexHtml(browserBaseHref));
this._update('push');
}