s Cocktail Homecoming Dress Short Dress Women Dark Halter Party Prom Lace Purple Backless DYS 5RBqAB
Casual Plus Women Dress Collar Size Chicwe with Ruffled Lily Lily Printed Dress Neckline Party Summer s and Black Split Floral Dress Women Ruffled and Split Neckline Floral Lily Casual with Dress Printed Summer Size Collar Plus Party Chicwe s Black Lily

Dress Party Dress Summer Split s Women with Chicwe Black Printed Casual Plus Size Lily Floral and Ruffled Lily Neckline Collar Z1zTwq

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