Short BD283 Prom Sleeve Party Back Beads Dresses Homecoming V White Dress BessDress Cap 5nWqwFAPgP
Summer Selfie Stretch Boob Beach Maxi Click Knot Teal Womens Maxi Teal Boob Stretch Click Summer Selfie Knot Womens Beach

Maxi Boob Beach Click Teal Summer Stretch Womens Knot Selfie 6qxv01

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