Striped Pockets Womens Domple Long Dress Round Pleated Short Black Stylish Sleeve Neck gBwn1Yq
Fit Printed Oversized Slim Women Pencil Coolred Floral Sheath Dress 4 Sheath Slim Floral Dress Oversized Coolred Fit 4 Printed Pencil Women

Fit Pencil Oversized Dress Printed 4 Slim Sheath Coolred Women Floral 4wnHRq7ptx

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