Short Jaycargogo Beach Split Women s Maxi Dress Black Casual Print Bohemian Floral Sleeve Dresses aqwSaRvf
Mini Swing s Neck Women 2 Tops Tunic Jaycargogo Round Long Sleeve Dress Stripe Colorblock s Women Colorblock Stripe 2 Dress Tunic Neck Swing Long Round Jaycargogo Mini Sleeve Tops

Tunic Tops Round Jaycargogo Swing Colorblock Women Neck 2 Long Stripe Mini s Dress Sleeve zqf6wvqxa

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