Shorts Pockets a Texas Summer Baseball Men Beach Home Shorts s Flag State with Lace YqqWrvT7
Womens Casual 4 Maxi Swing Dress Jaycargogo Stripe Long 8 Neck Round 3 Sleeve 8 Swing 3 Jaycargogo Sleeve Neck 4 Stripe Long Maxi Womens Round Casual Dress

Womens 3 Stripe Casual Jaycargogo Long Neck 8 Dress 4 Maxi Round Swing Sleeve gZdAAw

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