本文整理汇总了TypeScript中@angular/router.DefaultUrlSerializer.parse方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DefaultUrlSerializer.parse方法的具体用法?TypeScript DefaultUrlSerializer.parse怎么用?TypeScript DefaultUrlSerializer.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/router.DefaultUrlSerializer
的用法示例。
在下文中一共展示了DefaultUrlSerializer.parse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createState
function createState(
url: string,
outletName: string,
isPageNav: boolean = false,
isRoot: boolean = false) {
const urlSerializer = new DefaultUrlSerializer();
const stateUrlTree: UrlTree = urlSerializer.parse(url);
const rootOutlets = stateUrlTree.root.children;
return {
segmentGroup: isRoot ? stateUrlTree.root : rootOutlets[outletName],
isPageNavigation: isPageNav,
isRootSegmentGroup: isRoot,
};
}
示例2: it
it('returns the correct url', () => {
let originalUrl: string = '/explore-code/agencies/NASA';
let urlTree: UrlTree = defaultUrlSerializer.parse(originalUrl);
let actualUrl: string = customUrlSerializer.serialize(urlTree);
/* we're basically checking if the customer url serializer
* gives the same results as the default url serializer
* when there are no parentheses present
*/
expect(actualUrl).toEqual(originalUrl);
});
示例3: parse
parse(url: any): UrlTree {
let dus = new DefaultUrlSerializer();
return dus.parse(url);
}