0

Am using accordion with angular-2,but its not working properly,its throwing an error 404, its a third-party plugin named "ng2-accordion".

Path of the package that am giving is correct.

Actual bug in the inspect is given below.

  1. GET http://localhost:3000/ng2-accordion/ng2-accordion 404 (Not Found)
  2. Error: Error: XHR error (404 Not Found) loading http://localhost:3000/ng2-accordion/ng2-accordion(…)

enter image description here

sainu
  • 2,686
  • 3
  • 22
  • 41

4 Answers4

1

You need to add mapping to your system.js configuration like this:

{
    "map": {
        "ng2-accordion": "node_modules/ng2-accordion"
    },
    "packages": {
        "ng2-accordion": { "main": "index.js", "defaultExtension": "js" }
    }
}
pleerock
  • 18,322
  • 16
  • 103
  • 128
1

You need to check the directory structure for the ng2-accordion module. For example, for me the module is directory under node_modules.

So, specifying

import {ACCORDION_DIRECTIVES} from "ng2-accordion";

Instead of

import {ACCORDION_DIRECTIVES} from "ng2-accordion/ng2-accordion";
Usman Maqbool
  • 3,351
  • 10
  • 31
  • 48
Vishala
  • 11
  • 1
0

I think you need to configure your server to allow HTML5 pushState.

See also https://stackoverflow.com/a/36310728/217408

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • Sorry, I want to know, how to include an accordion in my project but it is not working,when the project was running,it showing error like above. – sainu May 03 '16 at 10:19
  • 1
    I know. . . . . I updated the link to an answer with more information. Try switching to `HashLocationStrategy` if this solves the problem and you want to use `PathLocationStrategy` then you need to configure your server instead. – Günter Zöchbauer May 03 '16 at 10:21
0

Is the Path correct http://localhost:3000/ng2-accordion/ng2-accordion ? If so you might have missed adding the defaultextension and also check the LocationStatergy, i would prefer HashLocation.

Pratik Kelwalkar
  • 1,592
  • 2
  • 15
  • 21