SamuraiJack
SamuraiJack

Reputation: 5539

Unexpected module 'NgAutoCompleteModule' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation

I am trying to implement autocomplete feature in my angular 2/4+ project. I have tried a number of libraries but none of them works. They give me similar error : Unexpected module 'NgAutoCompleteModule' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation

This is the library I am trying to use: ng2-input-autocomplete

I have followed all the steps except add mapping in systemjs config part. I can't find systemjs file in my project which was created using CLI

Upvotes: 1

Views: 577

Answers (1)

Arshmeet
Arshmeet

Reputation: 326

Problem: You are not including script file which has autocomplete code (the step that you skipped because you didn't find system.js file)

Solution: Since you are using angular cli you need to add this in your angular-cli.json file.

there would an array of scripts in your angular-cli.json file add this node_modules/ng2-input-autocomplete/bundles/ng2-input-autocompleteModule.umd.js to array.

Something like this ->

"scripts": [
            "../node_modules/ng2-input-autocomplete/bundles/ng2-input-autocompleteModule.umd.js",
            ...
            ...
          ],

Hope this helps

Upvotes: 1

Related Questions