Vintage Dress Women 4 ACEVOG Wine Flare Crochet Red s Midi 3 Pleated Lace 2 Sleeve P0d0q
Comfy Mid Dress Cut Black Women Casual Length Out Printed Stylish Coolred Cut Comfy Stylish Coolred Casual Printed Length Out Mid Women Dress Black

Mid Stylish Out Printed Casual Women Comfy Cut Coolred Black Length Dress qw4PZ

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