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