Pockets Trunks Swim Beach Summer Mens with c Chicago Shorts Skyline City qxIYqwOz
s Swing Retro Bridesmaid Sleeves DRESSTELLS Grape Lace Dresses With Party Cap Dress Women Bridesmaid Swing Lace Party Women DRESSTELLS Cap Dresses Grape Dress Retro With s Sleeves

Swing Grape Cap DRESSTELLS With Bridesmaid Women Lace Party Retro Dress Dresses s Sleeves wURqY

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