Floral Cocktail Picnic Formal Masquerade Vintage Garden Cocktail Spring Green Womens Dresses Dress Party Graduation Zhhmeiruian Evq1wCpxgW
Long 3 Dress Stripe Swing 8 Neck Maxi Sleeve 4 Casual Round Jaycargogo Womens Casual Maxi 4 Long Swing Stripe 3 Round Sleeve Womens 8 Neck Jaycargogo Dress

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