BSK78M Big Colorful PAIRS Men RioRiva 6 Fun Funky Calf Tall Dress Patterned Socks Shoe xXxPRqB8
Borje Fashion Evening 50s Formal Swing S Dresses XXL Multicolor Print Cocktail Dresses Optional Retro Vintage Optional Vintage Borje Swing Multicolor Cocktail Dresses Dresses XXL 50s S Print Fashion Retro Formal Evening

Borje Dresses Dresses Cocktail Print Evening Swing Multicolor Optional Retro 50s Vintage XXL Formal Fashion S rqv0Fr

A constructor parameter decorator that marks a dependency as optional.

See also

Description

The DI framework provides null if the dependency is not found. For example, the following code allows the possibility of a null result:

class Engine {} @ Injectable() class Car { constructor(@ Optional() public engine: Engine) {} } const injector = ReflectiveInjector.resolveAndCreate([Car]); expect(injector.get(Car).engine).toBeNull();
      
      class Engine {}

@Injectable()
class Car {
  constructor(@Optional() public engine: Engine) {}
}

const injector = ReflectiveInjector.resolveAndCreate([Car]);
expect(injector.get(Car).engine).toBeNull();
    

Options