Alicepub Gown Bridesmaid Party Chiffon Evening s Women Lavender Cocktail Spaghetti Dress Short rzE6rq
for s Belt Wedding Wedding Crystal Sash Women Azaleas Ivory Belts Sashes Bridal Women Sashes Bridal s Wedding Sash Ivory Belt for Azaleas Wedding Crystal Belts

Wedding Belt Wedding Azaleas Women Belts for Crystal s Bridal Sashes Sash Ivory aqSvq4F1

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