Floral Mini Short Women Irregular Sleeve 1 s Dress Swing Summer Domple w4Xtq87
Ivory s Sweetheart Dress Mesh David Long Bridesmaid Illusion Style Bridal Neckline F15927 Dress F15927 Bridesmaid Neckline Bridal Long Sweetheart Ivory Style s David Illusion Mesh

s Ivory Mesh David Bridesmaid Style Dress Long Bridal Illusion F15927 Sweetheart Neckline dPqFpw

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