Ball Evening Long Blue Dress royal Women Clearbridal Gown Lx559 Wedding Party Prom s qUfwx8S4
Sleeve Dress V Irregular Sexy Short Dress Tie Women Print Neck Midi Wrap Dress Wrap Irregular Short Neck Midi V Print Sexy Dress Tie Dress Dress Women Sleeve

Dress Print Neck Midi Dress Irregular Women V Tie Dress Wrap Sexy Short Sleeve 0qwBRO6

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