當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript LocationStrategy.onPopState方法代碼示例

本文整理匯總了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"
					});

				}

			}
		);

	}	
開發者ID:bennadel,項目名稱:JavaScript-Demos,代碼行數:30,代碼來源:retro-location.ts

示例2: constructor

  constructor(public platformStrategy: LocationStrategy) {
    super({ path: _path(platformStrategy), type: 'push' });

    platformStrategy.onPopState(event => this._update('pop'));

    this._baseHref = _getBaseHref(platformStrategy);
  }
開發者ID:gravity-addiction,項目名稱:router,代碼行數:7,代碼來源:router.ts

示例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');
  }
開發者ID:SekibOmazic,項目名稱:router,代碼行數:9,代碼來源:router.ts


注:本文中的@angular/common.LocationStrategy.onPopState方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。