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


TypeScript router_url_serializer.DefaultRouterUrlSerializer類代碼示例

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


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

示例1: describe

  describe('link', () => {
    let parser = new DefaultRouterUrlSerializer();

    it("should return the original tree when given an empty array", () => {
      let p = parser.parse("/");
      let t = link(s(p.root), p, []);
      expect(t).toBe(p);
    });

    it("should support going to root", () => {
      let p = parser.parse("/");
      let t = link(s(p.root), p, ["/"]);
      expect(parser.serialize(t)).toEqual("");
    });

    it("should support positional params", () => {
      let p = parser.parse("/");
      let t = link(s(p.root), p, ["/one", 11, "two", 22]);
      expect(parser.serialize(t)).toEqual("/one/11/two/22");
    });

    it("should preserve route siblings when changing the main route", () => {
      let p = parser.parse("/a/11/b(c)");
      let t = link(s(p.root), p, ["/a", 11, 'd']);
      expect(parser.serialize(t)).toEqual("/a/11/d(aux:c)");
    });

    it("should preserve route siblings when changing a aux route", () => {
      let p = parser.parse("/a/11/b(c)");
      let t = link(s(p.root), p, ["/a", 11, 'aux:d']);
      expect(parser.serialize(t)).toEqual("/a/11/b(aux:d)");
    });


    it('should update parameters', () => {
      let p = parser.parse("/a;aa=11");
      let t = link(s(p.root), p, ["/a", {aa: 22, bb: 33}]);
      expect(parser.serialize(t)).toEqual("/a;aa=22;bb=33");
    });
  });
開發者ID:844496869,項目名稱:angular,代碼行數:40,代碼來源:link_spec.ts

示例2: it

 it("should update relative subtree (when does not start with ./)", () => {
   let p = parser.parse("/a(ap)/c(cp)");
   let c = p.firstChild(p.root);
   let tree = s(c);
   let t = link(tree.root, tree, p, ["c2"]);
   expect(parser.serialize(t)).toEqual("/a(aux:ap)/c2(aux:cp)");
 });
開發者ID:davewragg,項目名稱:angular,代碼行數:7,代碼來源:link_spec.ts

示例3: it

    it("should parse key only matrix params", () => {
      let tree = url.parse("/one;a");

      let c = tree.firstChild(tree.root);
      expectSegment(c, "one");
      expectSegment(tree.firstChild(c), ";a=true");

      expect(url.serialize(tree)).toEqual("/one;a=true");
    });
開發者ID:844496869,項目名稱:angular,代碼行數:9,代碼來源:router_url_serializer_spec.ts

示例4: it

 it("should return the original tree when given an empty array", () => {
   let p = parser.parse("/");
   let t = link(s(p.root), p, []);
   expect(t).toBe(p);
 });
開發者ID:844496869,項目名稱:angular,代碼行數:5,代碼來源:link_spec.ts


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