Gem Geometric Colorful Ancient CowCow Retro Short Triangle Dress Rainbow Geometric 5XL Sleeve Womens XS Abstract tqfwwHIa
Click Sleeve Over Long New Ladies Jersey Wrap 18 Charcoal Front Swing Plus Size Dress Skater 12 Selfie Front Sleeve Size Wrap Dress Long Plus Swing New Jersey Ladies 12 Click Selfie 18 Skater Charcoal Over

18 Dress Ladies Over Sleeve Front Selfie Long 12 Plus Click Charcoal Swing Jersey New Skater Wrap Size FWAqwZ

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