Knee Shirt T s Dunland Sleeveless Multicolor10 Casual Length Loose Retro Women Dresses 5xwYYOqz10
4 Flare ANGVNS Women Vintage Collar Down Wine Style s Red Fit 3 Sleeve Turn 1 Party and Dress 4 Sleeve ANGVNS Collar 1 Down Party Style 3 Fit s and Dress Wine Women Turn Flare Red Vintage

Party Women Down Fit Sleeve Wine Style and Turn 1 3 Collar s Dress Red 4 Flare ANGVNS Vintage SUxO4d4w

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