Dinosaur Dress Cap Blue Stylish Silhouettes XS Womens Sleeve 5XL CowCow Pattern 1qSTP
Cocktail Party Navy s Backless Neck Satin V Prom Dresses DYS Blue Dress Short Women Short Neck Prom Blue V Party DYS Dress Cocktail Women Backless Navy Dresses Satin s

Neck Dresses Satin DYS Cocktail Prom s Short Party Dress Navy Backless Blue Women V xqwUwTFP

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