1 Womens A Line Midi Off Dress Low Fashional Shoulder Swing High Jaycargogo Pfdw6qY6
Party As1 Coolred Women High Comfy Sleeveless Dress Relaxed Rise Mini Comfy Party High Dress Rise Mini As1 Sleeveless Relaxed Women Coolred

As1 Comfy High Women Mini Coolred Dress Party Sleeveless Relaxed Rise 6Pqzn

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