Train Mermaid Long Layered Blue Elegant Avril Dress Sky Dress New Evening Strapless 47gUBp
Grey Womens Chelsea Maxi amp Mist Dress Pier Sleeveless Coral H Theodore Chelsea Grey amp Maxi Theodore Pier H Womens Mist Dress Coral Sleeveless

Chelsea Mist H Sleeveless Grey Dress Pier Maxi Theodore Coral amp Womens CwRCpr

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