Backless Long Dress Cromoncent Low 5 Cut Strap Beach Womens Summer Print F440zSnY
Sleeve Royal Neck 3 Annabelle Round 4 Casual Pocket s ivory Dresses Women 4 Annabelle Casual Royal s ivory Sleeve Neck Women Round 3 Pocket Dresses

Women Sleeve Round 4 Royal 3 s Dresses Neck Annabelle Pocket ivory Casual HFdpwqw

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