Wine Red High Womens Rise Summer Swing Maxi Lace Bowknot JSYAU Belt Dresses Floral qPt7nRwtFx
Neck Dress Swing Casual Round Stripe Womens 4 3 Maxi 8 Sleeve Long Jaycargogo 8 Long Round Dress Womens Casual Sleeve 4 Stripe Swing 3 Maxi Neck Jaycargogo

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