Printed Bow Yellow Strapless Women Dress Cocktail Fashion Coolred Classic CnAqw5
Jaycargogo Dress Stripe Womens Maxi Neck Casual Swing 3 Sleeve Round Long 4 8 Maxi 3 Swing Stripe Long Casual Dress 4 8 Sleeve Round Womens Jaycargogo Neck

Womens 3 Stripe Casual Jaycargogo Long Neck 8 Dress 4 Maxi Round Swing Sleeve gZdAAw

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