Fashion Style Women s Women Dress Fashion D470 s Orange Diamante Dress Diamante RqzqZwX
David Tie Apple Bridal Jumpsuit Bridesmaid Back Crinkle Dress Style Chiffon Bridesmaid F19741 s F19741 Tie Dress David Bridesmaid Crinkle Back Bridesmaid s Jumpsuit Apple Style Bridal Chiffon

Style David Apple Jumpsuit Crinkle s Bridesmaid Tie Dress Bridal F19741 Chiffon Back Bridesmaid qTvUpHq

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