The differenece in useValue / useFactory
mlc-mlapis opened this issue · comments
Miloš Lapiš commented
I'm submitting an ...
[x] Documentation issue or request
Current behavior
In our case, we tried to use error-tailor
package in the situation when it is used inside a lazy-loaded module (loaded programmatically) and error-tailor
was imported only on that level and not on the main app module level.
If it is used the following code with useFactory
, it works as expected.
If it is used with useValue
, it doesn't work. It would be probably helpful for others to explain those two variants explicitly in detail.
@NgModule({
declarations: [...],
imports: [
CommonModule,
ReactiveFormsModule,
ErrorTailorModule.forRoot({
errors: {
useFactory() {
return {
required: () => `This field is required`,
minLength: ({requiredLength, actualLength}) => `Expect ${requiredLength} but got ${actualLength}`,
invalidAddress: () => `Address not valid`
};
}
}
}),
routing,
...
]
})
export class LazyLoadedModule {...}
Netanel Basal commented
It is a typo. Check the new PR.