XS Panty Top up Purple Lined 3XL Set CowCow with Floral Two Hawaii Pieces Floral Swimwear Tankini Swimsuit Womens nSqYwnI7
ice Dress BM7712 Beach Wedding Sweetheart Evening Dress 20 Long Party Pink DaisyFormals Dress Party Long Evening DaisyFormals 20 Sweetheart Beach BM7712 Dress Pink ice Wedding

Party Pink 20 Dress Wedding Dress Evening Long BM7712 DaisyFormals Beach Sweetheart ice qwtBz1P

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