Coolred Ruffled Clubwear Women Waist Spring Floral Pattern1 Sleeveless Cocktail Dress IfSIqw
Autumn Women Sexy Dazzle DCB006 Long Sleeve Dresses Spring Bandage 04 Bodycon flash Stretch Black Party L Warm 04 Dazzle Long Autumn Stretch flash Dresses DCB006 L Black Bandage Bodycon Warm Spring Women Sleeve Party Sexy

Sleeve L Dazzle Autumn flash Long Spring Bodycon DCB006 Sexy Women Black Warm Party Dresses 04 Bandage Stretch aAIgAr

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