Angular CanLoad Guard

    0

    0

    lucycodes42

    Angular snippets for TypeScript

    This code imports the Injectable class from the Angular core library and also brings in the Route and CanLoad services. The NameGuard class implements the CanLoad interface, which means that it can check to see if a route can be loaded before trying to do anything else. In this case, the canLoad() method returns true, so the route will be loaded.

    Library: angular

    Shortcut: a_guard_can_load

    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.