Vintage Floral Solid Kids Baby Dresses Casual Cute Girl Pink Lace Dress Party Princess Dress 1CPw1qx0d
Gowns 2018 Evening BessWedding Women Mermaid BP022 Dresses s Prom Long Off Shoulder Black Gowns Prom Long Evening Off BP022 Women 2018 BessWedding Shoulder Dresses Black Mermaid s

s Evening BP022 Off 2018 Dresses BessWedding Black Gowns Prom Women Long Mermaid Shoulder 5qCx4Z1nwf

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