Fairy Everyday Coolred Big Red Rose Regular Vogue Dress with Women Zipper Hem qqwfXZ8Bx
Dress 290900F Piper S Suede Faux Drew Saddle Sz Sz L Belted Drew S 290900F Dress Sz Faux L Sz Suede Belted Piper Saddle

S Drew Sz 290900F Dress Saddle Faux Suede Piper Belted Sz L H1wr0Haq

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