Pattern Skirt Dress Fashion Aisa Sequin Lattice Shoulder Shining Green Women Party Strap Scale x07B6
Zhuhaitf Suit Designer Men Pants for Dress Pocket Father Trouser Gray Front Chino Formal Trousers Flat Trousers Office Pants Dress Trouser Trousers Office Formal Front Father Designer Gray for Flat Trousers Pocket Chino Men Pants Suit Zhuhaitf Pants

Pants Trousers Dress Office Men Pocket Father Gray for Flat Pants Front Trouser Zhuhaitf Chino Suit Designer Trousers Formal 7yqW5nO

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