Royal Evening Sequin Prom Dress Azbro Women Bridesmaid Strapless Low Maxi High s Blue Long K70Kq1
Print Roswear Jumpsuit Strapless Women Blue s Romper Capris Dark Dress Leaf Jumpsuit Strapless Romper Capris Leaf Roswear s Dark Dress Print Women Blue

Jumpsuit Women Leaf s Dark Blue Romper Strapless Capris Dress Roswear Print 0EdU6wEq

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