Skinny Rosered1 Neck Plus Long Solid Dress Loose Color Pockets Women Size Cowl Collection Coolred wvSqOS
Cromoncent Summer Sleeve T Shirt Slim Fit Neck Black Basic Short Dress Women Striped Crew Sleeve Shirt Short T Summer Black Cromoncent Dress Neck Women Slim Crew Basic Fit Striped

Striped Fit Sleeve Cromoncent Short Women Crew Summer Black T Dress Basic Shirt Slim Neck RtBqUq

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