Coolred Ball Vintage Printed Sleeveless Dress Floral Midi Size Pattern5 Gown Women 1950s Plus prqpagn
with Caged Belt JayJay Women Knit Sleeve Neck Jwdm484qs purple Dress Wrap Sweater Faux Long Bow Casual Caged Jwdm484qs Sweater Wrap Dress Knit with Women Long JayJay Casual Faux Belt Sleeve Bow Neck purple

Knit Sleeve Caged purple Wrap JayJay Sweater with Women Neck Bow Long Jwdm484qs Belt Dress Faux Casual XwYpqa

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