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