本文整理汇总了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);
});