Club Women Wine Dresses Dresses Halter Party Red Loose Maxi Jaycargogo Casual Bw0q0dZ
Dress Neck Steel Bride MACloth of Short Mother V Gown Evening Blue Women Sleeves Formal Blue Steel Short Mother Evening Bride Sleeves Formal Dress MACloth of Gown V Neck Women

Blue Gown Formal Dress Mother Steel Evening Sleeves Women Bride Short Neck of V MACloth fp6qO6

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