with Tunic Jaycargogo Casual Womens Hem Plain Pocket Irregular Dress 4 Neck V gzRwqg0
Sleeve Neck Beach Dress Shoulder Sweater V White Maxi Off Long Comfy Women Sleeve Dress Off White Maxi Neck V Sweater Long Comfy Beach Women Shoulder

Maxi Beach Sleeve Women Shoulder Sweater V Off Neck White Long Comfy Dress xUwEz8x

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