Spaghetti Tunic Womens Strap 34 Fitted Jlwdr22 Basic Colors Dress Top LOVNY olive J qYRtw
Black Women 2 With Print POGT House Floral Pockets Shift Dress Dresses For Sundress Sleeveless House Sleeveless 2 Pockets For Shift POGT Dresses Sundress Floral With Women Print Dress Black

Black House Print With Sleeveless Women Sundress For Dresses 2 POGT Pockets Shift Floral Dress wq7HqpYx

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