Flowers Damask Gray XS Womens Floral Dress Bohemia Paisley CowCow Paisley Sleeveless 5XL cU7A4cq
Tunic Pendulum Big Dresses Cromoncent Turtle Neck Womens Low Falbala Fit High Blue Slim Mock Slim Falbala Dresses Womens Mock High Low Fit Pendulum Big Blue Neck Cromoncent Turtle Tunic

Womens Falbala Slim Low Blue Turtle Mock Pendulum Fit Tunic Neck High Dresses Big Cromoncent qd6pAx6

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