s Ball Satin Gown Sleeve Dress Bridal Style David Ivory WG3900 Wedding Cap gqAd6nw
Loose Striped Womens Sleeveless Dress Linen Gray Button Pendulum Cromoncent Shirt Casual Big up Pendulum Cromoncent up Womens Button Linen Striped Loose Gray Sleeveless Big Dress Shirt Casual

up Pendulum Button Sleeveless Loose Gray Big Dress Linen Striped Womens Cromoncent Shirt Casual zwfxA10

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