How to use router.navigateByUrl and router.navigate in Angular

后端 未结 4 568
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 04:04

https://angular.io/api/router/RouterLink gives a good overview of how to create links that will take the user to a different route in Angular4, however I can\'t find how to

4条回答
  •  难免孤独
    2020-12-08 04:38

    In addition to the provided answer, there are more details to navigate. From the function's comments:

    /**
     * Navigate based on the provided array of commands and a starting point.
     * If no starting route is provided, the navigation is absolute.
     *
     * Returns a promise that:
     * - resolves to 'true' when navigation succeeds,
     * - resolves to 'false' when navigation fails,
     * - is rejected when an error happens.
     *
     * ### Usage
     *
     * ```
     * router.navigate(['team', 33, 'user', 11], {relativeTo: route});
     *
     * // Navigate without updating the URL
     * router.navigate(['team', 33, 'user', 11], {relativeTo: route, skipLocationChange: true});
     * ```
     *
     * In opposite to `navigateByUrl`, `navigate` always takes a delta that is applied to the current
     * URL.
     */
    

    The Router Guide has more details on programmatic navigation.

提交回复
热议问题