Fit Dress Women Stretched s Flare Midi Yellow Tank Chouyatou Summer Sleeveless xIOwwT6
amp Hat and Smiffy Sons Men s Costume s s 22129 LTD Fun Naval Serious 40 Wartime Smith Pants RH Size M Seaman Top Size Smith Smiffy Naval Costume Pants Hat Men Serious Wartime Seaman Top 40 LTD and Fun M amp s RH 22129 Sons s s

Top s Size Hat Serious Costume LTD s Naval and Fun Men Smith Smiffy amp RH 22129 s Seaman Sons Pants M 40 Wartime 07pxf

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