Angular Guard Can Load

    0

    0

    Jose Romero

    Angular TypeScript Recipes

    This code defines a class named NameGuard which implements the CanLoad interface. The class has a constructor which, when called, sets the property providedIn to root . The canLoad() method returns true so that the NameGuard class can be used to guard the loading of routes.

    Library: angular

    Shortcut: angular.guard.canload

    import { Injectable } from '@angular/core';
    import { CanLoad, Route } from '@angular/router';
    
    @Injectable({providedIn: 'root'})
    export class NameGuard implements CanLoad {
      constructor() { }
      canLoad(route: Route) {
        return true;
      }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.