Dress White Evening Dress Short Lace Lady Off Sleeve Linaking Shoulder Bodycon Mermaid Party Hipsters Fishtail The for Maxi Women 0Tfq6wU
lavender Vintage Chiffon Dress Dress Scoop Bridesmaid BM1552 DaisyFormals Neckline Party 7 Neckline Scoop Chiffon Dress 7 Party BM1552 Dress Vintage lavender DaisyFormals Bridesmaid

7 Chiffon lavender Party Dress Neckline Vintage DaisyFormals Bridesmaid Dress Scoop BM1552 xqz4OXwPnF

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