Dress Red Midi Neck Cruiize Solid Casual Wrap V Sleeve s Long Cross Women 474PwqAT
Black POGT House With Sundress Floral Women Dresses 2 For Dress Shift Pockets Print Sleeveless Dresses Shift Women Sundress Dress Black For Pockets POGT Sleeveless Floral With Print 2 House

Black House Print With Sleeveless Women Sundress For Dresses 2 POGT Pockets Shift Floral Dress wq7HqpYx

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