Autumn Sleeve Dress Coolred Stripes Commute Spring Purple Neck Step Crew Women One Half O4qE6xqB
Wrap Swing Slim Neck Dress Womens Midi Fit Midi Dress V Khaki Sleeve Jaycargogo Puff Khaki Sleeve Dress Womens Fit Midi Slim Puff Jaycargogo Midi Dress Neck V Wrap Swing

Khaki Dress Wrap Puff Neck Slim Fit Sleeve Midi Dress Swing Jaycargogo Midi V Womens w7Bqq6SO

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