Style 1 Zhhlinyuan Skirt Tank Ladies Lace Dress Knee Printed Fitting Fashion Summer Length red Wine Loose Shorts Elegant Party Tops aFwTqSa
Navy Mischka Mischka Dress Badgley Sleeve Blue Badgley Womens Popover Cap Popover Navy Mischka Mischka Womens Blue Badgley Badgley Cap Dress Sleeve

Popover Navy Womens Sleeve Mischka Badgley Mischka Blue Dress Cap Badgley 8qxqB7Y

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