Hat amp Boys Blue Set Pants Sky Trousers Outfits Clothes Sleeve Long Tops Navy Blue Baby Aliven OZqAvw85
Mermaid Wedding Bridal Bodice Applique Lace A7 Womens Annies Gown Sweetheart Neckline Annies Gown Bodice Neckline Lace Mermaid A7 Sweetheart Applique Wedding Bridal Womens

A7 Lace Wedding Neckline Applique Annies Gown Sweetheart Bodice Womens Bridal Mermaid TvxIqwaB6

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