0

I am trying to create a Instant Search Prototype using Algolia AngularJS module . I am using an app generated via jhipster (Micro Service Gateway) which uses Angular JS v1.x.

However when I launch my app I get this error: enter image description here

I ran the following commands to install algolia search js module

1. npm install algoliasearch --save
2. bower install algoliasearch -S
3. Added algoliasearch as a dependency in app.module.js

I also cross checked all relevant files (See Below) but couldnt find any problems. Other modules are loaded properly.

  1. index.html : This has script tag for algoliasearch.js file which is present locally: enter image description here

  2. bower.json has algoliasearch js client installed properly and I can see algoliasearch folder under bower_components enter image description here

  3. Here is where I have added algoliasearch js module app.module.js enter image description here

Not sure if I have missed anything. Any help on resolving this issue would be great.

Update 11/20: Thanks to the Answers here. I got this working by adding the following to my bower.json file

"algoliasearch": {
    "main":[
        "dist/algoliasearch.js",
        "dist/algoliasearch.angular.js"
     ],
    "dependencies": {
        "angular": "1.5.8"
    }
},
Dhananjay
  • 642
  • 6
  • 15

2 Answers2

2

You need to include angular specific build something like

algoliasearch.angular.min.js

And also put script include of angular.js above this.

Sunil B N
  • 4,159
  • 1
  • 31
  • 52
1

Specific to JHipster: to get algoliasearch.angular.js automatically included you need to add it to your project's bower.json file like what we already do for other dependencies when their bower.json does not include enough files (too many) required in our context:

"overrides": {
    "algoliasearch ": {
      "main": [
        "dist/algoliasearch.js",
        "dist/algoliasearch.angular.js"
      ]
    },

Don't forget to run gulp or gulp inject after editing bower.json to inject these 2 scripts (see documentation on recommended workflow to run both mvn/gradle and gulp)

No need to include minified versions of these files as they'll get minified by JHipster gulp build process.

Gaël Marziou
  • 16,028
  • 4
  • 38
  • 49
  • Thank You. This did it. Although I also had to add angular as a dependency for algoliasearch as suggested by @sunil B N. – Dhananjay Nov 20 '16 at 15:05
  • That's weird because if you did this and run either `gulp serve` or `gulp inject`, it should have inserted algoliasearch.angular.js as well. – Gaël Marziou Nov 20 '16 at 17:10