Half Off Sleeve Gown Mermaid Shoulder Dress Wine Women Solid Maxi Bodycon Evening Blansdi 5qSFtH6
Bodycon 12 Domple Casual Dress Crewneck Midi Women Elastic s Basic Solid Color Domple 12 Midi Color Casual Bodycon s Elastic Crewneck Solid Basic Dress Women

Basic 12 Domple Color Elastic Midi s Women Dress Solid Bodycon Crewneck Casual 1wqT6wP0

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