question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Right way to import ng2-select

See original GitHub issue

What is the right way to import this module in a Angular2 project ?

Currently, I import the module this way: app.module.ts

import { SelectModule } from '../node_modules/ng2-select/components/select.module.ts';
@NgModule({
    imports: [
        BrowserModule,
        FormsModule,
        HttpModule,
        ...
        SelectModule, // ng2-select
    ],
....

But I have an error:

zone.js:1263 GET http://localhost:55976/traceur 404 (Not Found) (index):31 Error: Error: XHR error (404 Not Found) loading http://localhost:55976/traceur(…)

What am I doing wrong?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

12reactions
chris--jonescommented, Oct 6, 2016

I had a bit of trouble getting this working as well. Are you using systemjs?

If so add the following to systemjs.config.js:

map: {
 ...
 'ng2-select': 'node_modules/ng2-select'
}

packages: {
    ...
    'ng2-select': {
        defaultExtension: 'js',
        main: 'ng2-select.js'
    }
}

Then in the component you want to use the control:

import { SelectComponent } from 'ng2-select';`
@Component({
    selector: 'main',
    template: `<div>
        <ng-select
                [multiple]="true"
                [items]="filterItems"
                (data)="setFilterSelection($event)"
                placeholder="Click or type to filter"></ng-select>
    </div>
})
export class MainComponent {
    private filterSelection: string[];
    public filterItems: string[] = ["alpha","beta","gamma"];
    public setFilterSelection(value: any): void {
        this.filterSelection = value;
    }
}
4reactions
georgebejancommented, Oct 10, 2016

@BenDevelopment you are having that error because of this line:

import { SelectModule } from '../node_modules/ng2-select/components/select.module.ts';

replace it with

import {SelectModule} from "ng2-select";

and it should disappear.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular2 : trouble in integrating ng2-select - Stack Overflow
import { SelectModule } from "ng2-select/ng2-select";. then add "SelectModule" to the NgModule.imports array. Now in your component add the following import ...
Read more >
ng2-select - npm
Start using ng2-select in your project by running `npm i ng2-select`. There are 27 other projects in the npm registry using ng2-select.
Read more >
Angular Select - Valor Software
API. Usage. import {SelectModule} from 'ng2-select';. Annotations. // class Select @Component ...
Read more >
ng2-select2 - npm Package Health Analysis - Snyk
ng2 -select2 · Angular2 wrapper for select2 For more information about how to use this package see README · Security · Popularity ·...
Read more >
Can't import ng2-select SelectComponent - Stack Overflow
I'm trying to fix an issues in valor-software library ng2-select after install it in my node_modules ( npm install --save ng2-select ) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found