5

I know that there are a lot of questions answered for this particular error but after trying out the combination of those solutions, none tend to help with this package.

ng2-mdf-validation-messages - https://www.npmjs.com/package/ng2-mdf-validation-messages

There is also an issue still open on GitHub for the same - https://github.com/d-kostov-dev/ng2-mdf-validation-messages/issues/12

Various solutions for different packages mention to export a function and include it via useFactory but I am not getting as what to write for this particular package.

Eg:

import { Ng2MDFValidationMessagesModule } from 'ng2-mdf-validation-messages';

export function Ng2MDFValidationMessagesModuleFactory() {
    return Ng2MDFValidationMessagesModule.globalConfig({
        class: 'text-danger',
        defaultErrorMessages: {
            required: 'Default Custom Required Message'
        }
    });
}

@NgModule({
    ...
    providers: [
        {
            provide: Ng2MDFValidationMessagesModule,
            useFactory: Ng2MDFValidationMessagesModuleFactory
        }
    ],
})

It still gives the error if tried on a completely new app created with ng.

After editing any file and saving resolves the error and everything works fine afterwards but not for the first time.

Add a sample code with fresh install using Angular 4 and this plugin.
Available at - https://github.com/kunaldethe/ng4-mdf-validation-messages-example

Configuration:

1. node -v (v6.11.0)
2. npm -v (5.4.2)
3. ng --version
    @angular/cli: 1.4.9
    node: 6.11.0
    os: win32 x64
    @angular/animations: 4.4.6
    @angular/common: 4.4.6
    @angular/compiler: 4.4.6
    @angular/core: 4.4.6
    @angular/forms: 4.4.6
    @angular/http: 4.4.6
    @angular/platform-browser: 4.4.6
    @angular/platform-browser-dynamic: 4.4.6
    @angular/router: 4.4.6
    @angular/cli: 1.4.9
    @angular/compiler-cli: 4.4.6
    @angular/language-service: 4.4.6
    typescript-formatter: 5.2.0
    typescript: 2.3.4

Any help is appreciated.

Kunal Dethe
  • 1,254
  • 1
  • 18
  • 38
  • What about the suggestion in issue? https://github.com/d-kostov-dev/ng2-mdf-validation-messages/issues/12#issuecomment-341137445 – yurzui Nov 09 '17 at 19:33
  • Which angular version are you using? – yurzui Nov 09 '17 at 19:34
  • @yurzui that suggestion was added by me. It suppresses the error during `ng serve` but does not resolve the issue. Instead the plugin stops working without throwing any error. – Kunal Dethe Nov 10 '17 at 06:44
  • I tried your code from question and ngc works without any error in angular 5 – yurzui Nov 10 '17 at 06:46
  • @yurzui updated the question with the configuration details. Yes, with the above code, the `ng serve` stops giving the error in Angular 4 too. But then the plugin does not work in the code. Which means the error is suppressed but the issue is not resolved. – Kunal Dethe Nov 10 '17 at 06:55
  • @yurzui give me few mins, will create a new repo with fresh Angular 4 app code and include the plugin in it. Just running `npm install` and then `ng serve` will get it started. The sample code given at https://github.com/d-kostov-dev/ng2-mdf-validation-messages README.md file is not that perfect. – Kunal Dethe Nov 10 '17 at 07:01
  • @yurzui created a new repo. with sample code at https://github.com/kunaldethe/ng4-mdf-validation-messages-example – Kunal Dethe Nov 10 '17 at 08:09
  • This library doesn't ship metadata. angular-cl fires `_getLazyRoutesFromNgtools` at first run and it executes statically analysis code – yurzui Nov 10 '17 at 09:54
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/158679/discussion-between-kunal-dethe-and-yurzui). – Kunal Dethe Nov 10 '17 at 10:10
  • npm states that that package is built on Angular 2.1.2 It's possible that something has been deprecated since then. https://www.npmjs.com/package/ng2-mdf-validation-messages – Brian Wright Nov 16 '17 at 14:18
  • @BrianWright Yes, it was built when Angular 2.* was the latest version. Thing is that this package works really great and minimizes the code to one single line instead of 10s. So I want to use it in Angular 4.* too. `@yurzi` has pointed out the issue that the package does not ship with metadata file(s). It would really help to know how to generate them. – Kunal Dethe Nov 17 '17 at 09:30
  • Ah gotcha, did you put in a ticket with the developer regarding the compatibility issue? – Brian Wright Nov 17 '17 at 13:55
  • @BrianWright Sorry was away. If you mean by an issue raised on GitHub then it is already done by someone else - https://github.com/d-kostov-dev/ng2-mdf-validation-messages/issues/12 – Kunal Dethe Nov 24 '17 at 07:49
  • Cool, thanks for the link! – Brian Wright Nov 29 '17 at 16:29

0 Answers0