Bridesmaid Back David s Bridal Crinkle Bridesmaid Dress Mercury Style F19741 Jumpsuit Tie Chiffon XxEnwUqn
Irregular Women Dress AU Hem Hoodie Casual Drawstring Top Purple QianQian s Long Long Casual s Drawstring Dress Purple Hoodie Hem Women QianQian Irregular AU Top

s Women QianQian AU Top Hoodie Hem Drawstring Long Irregular Casual Dress Purple Oqqw5TE

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