Women Black Hem 4 Donna Stripe Ponte Sleeve White Knit Ruffle Sheath in s 3 Morgan Dress 5fqSwxWqHO
BM3728 Cocktail Dress Chiffon Halter Short navy Bridesmaid 35 Party Dress DaisyFormals Party Chiffon Short DaisyFormals 35 BM3728 Dress Dress navy Cocktail Bridesmaid Halter

navy Dress BM3728 Bridesmaid Cocktail DaisyFormals 35 Dress Chiffon Halter Short Party qwwBU0v

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