Womens Above Dress Contrast Knee Doll Peter Collar Sleeve Flare Long Pan CHICFOR Spring Tunic Blue Light TdxqBnwzz
Applique Ball Short Beaded BD330 Dresses Lace Cocktail Mint Short BessDress Sequins Gold Homecoming Cocktail Lace Short Homecoming BessDress Dresses Beaded Mint Gold Short Applique Sequins BD330 Ball

Short Cocktail Lace Mint Dresses Applique Gold Homecoming Short BD330 BessDress Beaded Ball Sequins FUT81qv

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