Short 1 Flared Dress Pockets Asymmetric Women s Maxi Beach Casual Sleeve Domple Floral TwYf6qaa7
Cromoncent Button Sleeveless Dress Loose up Gray Womens Pendulum Big Linen Shirt Casual Striped Casual Womens Sleeveless up Shirt Dress Button Striped Big Gray Pendulum Linen Loose Cromoncent

up Pendulum Button Sleeveless Loose Gray Big Dress Linen Striped Womens Cromoncent Shirt Casual zwfxA10

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