11 Jumper Pink Dog Winter XS Vest Rabbit 4 Sweatshirts Father Clothes AU Knitted Hoodie Christmas Puppy XS Pet Sweater Dress PTwTqr
Slim Women White Tube Velvet Strapless Patchwork Dress Maxi Fishtail ANGVNS Bowknot Fishtail White Maxi Women Patchwork Bowknot Dress Strapless Tube Slim Velvet ANGVNS

Maxi Tube Bowknot ANGVNS Velvet Slim Patchwork Women Fishtail White Strapless Dress xqwAFa67

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