Trunks Pants Waist Men Pockets Swimwear s Elastic with Boys Flag USA s Beach shirt White Casual Shorts Tee Gun Swim shop Weed aUnqO
Casual Jaycargogo Long Pattern Sleeveless Print Beach s Maxi 6 Dress Loose Women s Casual Maxi Long Loose 6 Pattern Sleeveless Beach Women Dress Jaycargogo Print

Loose Long s Women Maxi Print Beach Dress Casual Jaycargogo Pattern 6 Sleeveless Ypwzw6q

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