Beaded Party Prom MALL Chiffon BRL Long Line s Dresses Wedding Women Crystal A White Gowns gq7Yx8U
Suit Men Trousers Chino Pocket Front Flat Father Formal Gray for Office Trousers Designer Dress Trouser Pants Zhuhaitf Pants Chino Men Flat Father Pants Pocket for Zhuhaitf Pants Dress Office Designer Trousers Suit Trouser Gray Trousers Front Formal

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