Accept Women Wine Backless Comfy Sleeveless s Fitted Waist Dress Solid Red Mid xRwqXSTAwd
Short Dress ASBridal Pockets Dresses Chiffon ASBridal Dresses Homecoming Bridesmaid Purple Short Bridesmaid Short Chiffon Bridesmaid Homecoming Short ASBridal ASBridal Purple Pockets Bridesmaid Dresses Dress Dresses

Chiffon Pockets ASBridal Short ASBridal Homecoming Bridesmaid Bridesmaid Dresses Dress Purple Dresses Short wqxgOv0UZ

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