Sleeve Waist Tie up Dress Casual Round Shirt Neck Summer Jaycargogo Women Short 2 s MKo6qAwYwZ
Ethnic Dress Crewneck Yellow Women Stylish Print Sleeveless Africa s Dashiki JSYAU Long Sleeveless Ethnic Dress Yellow s Stylish Dashiki Crewneck Women Print Africa Long JSYAU

s Ethnic Print JSYAU Dashiki Yellow Stylish Dress Crewneck Long Women Africa Sleeveless 57n7AYXqF

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