green Swing Women 262 Classical Belt ADAMARIS Vintage Sleeveless Neck Figures Dress s Boat with fw0ZH
Backless Black2 Bohemia A Flowy Big Womens Flare Line Print Tang Dress Floral Black2 A Line Tang Backless Flare Dress Bohemia Flowy Big Print Womens Floral

Bohemia Backless Floral Tang Line Dress Big Flare Print Womens Flowy A Black2 x4qpxIXw

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