Angular Resolver

    0

    0

    Jose Romero

    Angular TypeScript Recipes

    The code above defines a class called YourResolver which implements the Resolve<ObjectToResolve> interface. In order to use this class, you need to inject it into a class that wants to use it. The providedIn property on the YourResolver class indicates that it can be injected into the root class.

    The resolve method takes a route object as its only argument. The route object represents the path of the page or route that the resolving object should be applied to. The resolve method will return three possible values: an Observable, a Promise, or an ObjectToResolve. The first two values will contain the result of resolving the route. The third value will be the resolved object.

    Library: angular

    Shortcut: angular.resolver

    import { Injectable } from '@angular/core';
    import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
    import { Observable } from 'rxjs';
    
    @Injectable({ providedIn: 'root' })
    export class YourResolver implements Resolve<ObjectToResolve> {
      resolve(route: ActivatedRouteSnapshot): Observable<ObjectToResolve> | Promise<ObjectToResolve> | ObjectToResolve {
        return ;
      }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.