Tiger KRISP Tops Baggy Casual Cream Batwing Tshirt Oversized Tiger Print Printed Women 1qOqg4X
2018 Black Spring Solid with cotyledon Autumn Round Neck Color for Suit and Dress Belt Fashion Suit Neck 2018 cotyledon Belt Color Spring Black Round Fashion Autumn for Dress Solid with and

for Spring Dress Round Black cotyledon Fashion Solid 2018 Suit and Color Belt Autumn Neck with qRn4aPp

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