your recipe card header background

    Angular Module SkipSelf Constructor

    0

    1

    lucycodes42

    Angular snippets for TypeScript

    The code creates a constructor that takes one argument, @Optional(). If the argument is not null, then the parentModule property is set to the argument. If the argument is null, then the parentModule property is set to the empty string. The constructor then prints a message telling the user that ModuleName has already been loaded.

    Library: angular

    Shortcut: a_ctor_skip_self

    constructor( @Optional() @SkipSelf() parentModule: ModuleName {
      if (parentModule) {
        const msg = `ModuleName has already been loaded. 
          Import ModuleName once, only, in the root AppModule.`;
        throw new Error(msg);
      }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.