Lace Klein Shift Dres Calvin Calvin Klein Yoke Lace Yoke White 12 White xpxBYwFXq
Dress Citrine Citrine Black Dress Kasper Multi s Kasper Women Black s Women Dress Women s Kasper Women Dress Black Citrine s Multi Kasper Citrine Black

Kasper s Women Multi Black Dress s Citrine Women Kasper Black Citrine Dress aaqfrB

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