Dresses Short Women s Bridesmaid Lavender Mint Anna Beaded Bridal s Chiffon High Low vU6cPZyTH
Floral Aecibzo Long Pockets Cold Party Women Shoulder Gold Skirts s Dress Print Piece Two blue Print Cold Piece Party Women Dress Skirts Floral Shoulder blue Long Aecibzo Gold Pockets Two s

Party Cold Gold Long Two Floral s Aecibzo Piece Skirts Dress Shoulder Pockets Print blue Women vxTEFpqwR

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