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


TypeScript core.UrlService類代碼示例

本文整理匯總了TypeScript中@uirouter/core.UrlService的典型用法代碼示例。如果您正苦於以下問題:TypeScript UrlService類的具體用法?TypeScript UrlService怎麽用?TypeScript UrlService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了UrlService類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: platformBrowserDynamic

platformBrowserDynamic().bootstrapModule(KyloModule).then(platformRef => {
    const injector: Injector = platformRef.injector;
    const upgrade = injector.get(UpgradeModule) as UpgradeModule;

    // The DOM must be already be available
    upgrade.bootstrap(document.body, ["kylo"]);

    // Initialize the Angular Module (get() any UIRouter service from DI to initialize it)
    const url: UrlService = injector.get(UIRouter).urlService;//getUIRouter(injector).urlService;

    // Instruct UIRouter to listen to URL changes
    url.listen();
    url.sync();
});
開發者ID:prashanthc97,項目名稱:kylo,代碼行數:14,代碼來源:main.ts

示例2: platformBrowserDynamic

platformBrowserDynamic().bootstrapModule(SampleAppModuleAngular).then(platformRef => {
  // Initialize the Angular Module
  // get() the UIRouter instance from DI to initialize the router
  const urlService: UrlService = platformRef.injector.get(UIRouter).urlService;

  // Instruct UIRouter to listen to URL changes
  function startUIRouter() {
    urlService.listen();
    urlService.sync();
  }

  platformRef.injector.get<NgZone>(NgZone).run(startUIRouter);
});
開發者ID:ui-router,項目名稱:sample-app-ng1-to-ng2,代碼行數:13,代碼來源:main.ts

示例3: it

    it('should be wrapped in an array if array: true', function() {
      const m = $umf.compile('/foo?param1', { params: { param1: { array: true } } });

      // empty array [] is treated like "undefined"
      expect(m.format({ param1: undefined })).toBe('/foo');
      expect(m.format({ param1: [] })).toBe('/foo');
      expect(m.format({ param1: '' })).toBe('/foo');
      expect(m.format({ param1: '1' })).toBe('/foo?param1=1');
      expect(m.format({ param1: ['1'] })).toBe('/foo?param1=1');
      expect(m.format({ param1: ['1', '2'] })).toBe('/foo?param1=1&param1=2');

      expect(m.exec('/foo')).toEqual({ param1: undefined });
      expect(m.exec('/foo', {})).toEqual({ param1: undefined });
      expect(m.exec('/foo', { param1: '' })).toEqual({ param1: undefined });
      expect(m.exec('/foo', { param1: '1' })).toEqual({ param1: ['1'] });
      expect(m.exec('/foo', { param1: ['1', '2'] })).toEqual({ param1: ['1', '2'] });

      $url.url('/foo');
      expect(m.exec($url.path(), $url.search())).toEqual({ param1: undefined });
      $url.url('/foo?param1=');
      expect(m.exec($url.path(), $url.search())).toEqual({ param1: undefined });
      $url.url('/foo?param1=bar');
      expect(m.exec($url.path(), $url.search())).toEqual({ param1: ['bar'] });
      $url.url('/foo?param1=bar&param1=baz');
      if (angular.isArray($url.search()))
        // conditional for angular 1.0.8
        expect(m.exec($url.path(), $url.search())).toEqual({ param1: ['bar', 'baz'] });

      expect(m.format({})).toBe('/foo');
      expect(m.format({ param1: undefined })).toBe('/foo');
      expect(m.format({ param1: '' })).toBe('/foo');
      expect(m.format({ param1: 'bar' })).toBe('/foo?param1=bar');
      expect(m.format({ param1: ['bar'] })).toBe('/foo?param1=bar');
      expect(m.format({ param1: ['bar', 'baz'] })).toBe('/foo?param1=bar&param1=baz');
    });
開發者ID:angular-ui,項目名稱:ui-router,代碼行數:35,代碼來源:urlMatcherFactorySpec.ts


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