JHipster and Angular ng-select component












2















I'm developing an app using the latest version of JHipster where I'm trying to show a multiple select dropdown by using a {<ng-select>} module from https://github.com/ng-select/ng-select. But it's not displayed.
Here is the code below.
My app.module.ts file:



import { FormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
// jhipster-needle-angular-add-module-import JHipster will add new module here
import { JhiMainComponent, NavbarComponent, FooterComponent, PageRibbonComponent, ActiveMenuDirective, ErrorComponent } from './layouts';

@NgModule({
imports: [
BrowserModule,
NgSelectModule,
FormsModule,
MyAppAppRoutingModule,
Ng2Webstorage.forRoot({ prefix: 'jhi', separator: '-' }),
MyAppSharedModule,
MyAppCoreModule,
MyAppHomeModule,
MyAppAccountModule,
// jhipster-needle-angular-add-module JHipster will add new module here
MyAppEntityModule
],
declarations: [JhiMainComponent, NavbarComponent, ErrorComponent, PageRibbonComponent, ActiveMenuDirective, FooterComponent],
providers: [
-----------
],
bootstrap: [JhiMainComponent]
})
...........


The DataService:



export interface Person {
id: string;
isActive: boolean;
age: number;
name: string;
gender: string;
company: string;
email: string;
phone: string;
disabled?: boolean;
}
@Injectable({ providedIn: 'root' })
export class DataService {
.......

constructor(private http: HttpClient) {}
........

getPeople(term: string = null): Observable<Person> {
let items = getMockPeople();
if (term) {
items = items.filter(x => x.name.toLocaleLowerCase().indexOf(term.toLocaleLowerCase()) > -1);
}
return of(items).pipe(delay(500));
}

}

function getMockPeople() {
return [
{
'id': '5a15b13c36e7a7f00cf0d7cb',
'index': 2,
'isActive': true,
'picture': 'http://placehold.it/32x32',
'age': 23,
'name': 'Karyn Wright',
'gender': 'female',
'company': 'ZOLAR',
'email': 'karynwright@zolar.com',
'phone': '+1 (851) 583-2547'
},
{
'id': '5a15b13c2340978ec3d2c0ea',
'index': 3,
'isActive': false,
'picture': 'http://placehold.it/32x32',
'age': 35,
'name': 'Rochelle Estes',
'disabled': true,
'gender': 'female',
'company': 'EXTRAWEAR',
'email': 'rochelleestes@extrawear.com',
'phone': '+1 (849) 408-2029'
}
];
}


the people component:



    export class PeopleUpdateComponent implements OnInit {
people$3: Observable<any>;
selectedPeople3 = ;

constructor(
private jhiAlertService: JhiAlertService,
private dataService: DataService,
private activatedRoute: ActivatedRoute
) {}

ngOnInit() {
this.isSaving = false;
this.people$3 = this.dataService.getPeople();
}
}


My html code is:



<ng-select
[items]="people$3 | async"
bindLabel="name"
[multiple]="true"
[disabled]="disable"
[(ngModel)]="selectedPeople3">
</ng-select>


Any help is appreciated










share|improve this question




















  • 2





    Other users will be able to provide better assistance if you post your present code, what is presently happening and your intended output.

    – Simon.S.A.
    Nov 24 '18 at 19:31
















2















I'm developing an app using the latest version of JHipster where I'm trying to show a multiple select dropdown by using a {<ng-select>} module from https://github.com/ng-select/ng-select. But it's not displayed.
Here is the code below.
My app.module.ts file:



import { FormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
// jhipster-needle-angular-add-module-import JHipster will add new module here
import { JhiMainComponent, NavbarComponent, FooterComponent, PageRibbonComponent, ActiveMenuDirective, ErrorComponent } from './layouts';

@NgModule({
imports: [
BrowserModule,
NgSelectModule,
FormsModule,
MyAppAppRoutingModule,
Ng2Webstorage.forRoot({ prefix: 'jhi', separator: '-' }),
MyAppSharedModule,
MyAppCoreModule,
MyAppHomeModule,
MyAppAccountModule,
// jhipster-needle-angular-add-module JHipster will add new module here
MyAppEntityModule
],
declarations: [JhiMainComponent, NavbarComponent, ErrorComponent, PageRibbonComponent, ActiveMenuDirective, FooterComponent],
providers: [
-----------
],
bootstrap: [JhiMainComponent]
})
...........


The DataService:



export interface Person {
id: string;
isActive: boolean;
age: number;
name: string;
gender: string;
company: string;
email: string;
phone: string;
disabled?: boolean;
}
@Injectable({ providedIn: 'root' })
export class DataService {
.......

constructor(private http: HttpClient) {}
........

getPeople(term: string = null): Observable<Person> {
let items = getMockPeople();
if (term) {
items = items.filter(x => x.name.toLocaleLowerCase().indexOf(term.toLocaleLowerCase()) > -1);
}
return of(items).pipe(delay(500));
}

}

function getMockPeople() {
return [
{
'id': '5a15b13c36e7a7f00cf0d7cb',
'index': 2,
'isActive': true,
'picture': 'http://placehold.it/32x32',
'age': 23,
'name': 'Karyn Wright',
'gender': 'female',
'company': 'ZOLAR',
'email': 'karynwright@zolar.com',
'phone': '+1 (851) 583-2547'
},
{
'id': '5a15b13c2340978ec3d2c0ea',
'index': 3,
'isActive': false,
'picture': 'http://placehold.it/32x32',
'age': 35,
'name': 'Rochelle Estes',
'disabled': true,
'gender': 'female',
'company': 'EXTRAWEAR',
'email': 'rochelleestes@extrawear.com',
'phone': '+1 (849) 408-2029'
}
];
}


the people component:



    export class PeopleUpdateComponent implements OnInit {
people$3: Observable<any>;
selectedPeople3 = ;

constructor(
private jhiAlertService: JhiAlertService,
private dataService: DataService,
private activatedRoute: ActivatedRoute
) {}

ngOnInit() {
this.isSaving = false;
this.people$3 = this.dataService.getPeople();
}
}


My html code is:



<ng-select
[items]="people$3 | async"
bindLabel="name"
[multiple]="true"
[disabled]="disable"
[(ngModel)]="selectedPeople3">
</ng-select>


Any help is appreciated










share|improve this question




















  • 2





    Other users will be able to provide better assistance if you post your present code, what is presently happening and your intended output.

    – Simon.S.A.
    Nov 24 '18 at 19:31














2












2








2








I'm developing an app using the latest version of JHipster where I'm trying to show a multiple select dropdown by using a {<ng-select>} module from https://github.com/ng-select/ng-select. But it's not displayed.
Here is the code below.
My app.module.ts file:



import { FormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
// jhipster-needle-angular-add-module-import JHipster will add new module here
import { JhiMainComponent, NavbarComponent, FooterComponent, PageRibbonComponent, ActiveMenuDirective, ErrorComponent } from './layouts';

@NgModule({
imports: [
BrowserModule,
NgSelectModule,
FormsModule,
MyAppAppRoutingModule,
Ng2Webstorage.forRoot({ prefix: 'jhi', separator: '-' }),
MyAppSharedModule,
MyAppCoreModule,
MyAppHomeModule,
MyAppAccountModule,
// jhipster-needle-angular-add-module JHipster will add new module here
MyAppEntityModule
],
declarations: [JhiMainComponent, NavbarComponent, ErrorComponent, PageRibbonComponent, ActiveMenuDirective, FooterComponent],
providers: [
-----------
],
bootstrap: [JhiMainComponent]
})
...........


The DataService:



export interface Person {
id: string;
isActive: boolean;
age: number;
name: string;
gender: string;
company: string;
email: string;
phone: string;
disabled?: boolean;
}
@Injectable({ providedIn: 'root' })
export class DataService {
.......

constructor(private http: HttpClient) {}
........

getPeople(term: string = null): Observable<Person> {
let items = getMockPeople();
if (term) {
items = items.filter(x => x.name.toLocaleLowerCase().indexOf(term.toLocaleLowerCase()) > -1);
}
return of(items).pipe(delay(500));
}

}

function getMockPeople() {
return [
{
'id': '5a15b13c36e7a7f00cf0d7cb',
'index': 2,
'isActive': true,
'picture': 'http://placehold.it/32x32',
'age': 23,
'name': 'Karyn Wright',
'gender': 'female',
'company': 'ZOLAR',
'email': 'karynwright@zolar.com',
'phone': '+1 (851) 583-2547'
},
{
'id': '5a15b13c2340978ec3d2c0ea',
'index': 3,
'isActive': false,
'picture': 'http://placehold.it/32x32',
'age': 35,
'name': 'Rochelle Estes',
'disabled': true,
'gender': 'female',
'company': 'EXTRAWEAR',
'email': 'rochelleestes@extrawear.com',
'phone': '+1 (849) 408-2029'
}
];
}


the people component:



    export class PeopleUpdateComponent implements OnInit {
people$3: Observable<any>;
selectedPeople3 = ;

constructor(
private jhiAlertService: JhiAlertService,
private dataService: DataService,
private activatedRoute: ActivatedRoute
) {}

ngOnInit() {
this.isSaving = false;
this.people$3 = this.dataService.getPeople();
}
}


My html code is:



<ng-select
[items]="people$3 | async"
bindLabel="name"
[multiple]="true"
[disabled]="disable"
[(ngModel)]="selectedPeople3">
</ng-select>


Any help is appreciated










share|improve this question
















I'm developing an app using the latest version of JHipster where I'm trying to show a multiple select dropdown by using a {<ng-select>} module from https://github.com/ng-select/ng-select. But it's not displayed.
Here is the code below.
My app.module.ts file:



import { FormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
// jhipster-needle-angular-add-module-import JHipster will add new module here
import { JhiMainComponent, NavbarComponent, FooterComponent, PageRibbonComponent, ActiveMenuDirective, ErrorComponent } from './layouts';

@NgModule({
imports: [
BrowserModule,
NgSelectModule,
FormsModule,
MyAppAppRoutingModule,
Ng2Webstorage.forRoot({ prefix: 'jhi', separator: '-' }),
MyAppSharedModule,
MyAppCoreModule,
MyAppHomeModule,
MyAppAccountModule,
// jhipster-needle-angular-add-module JHipster will add new module here
MyAppEntityModule
],
declarations: [JhiMainComponent, NavbarComponent, ErrorComponent, PageRibbonComponent, ActiveMenuDirective, FooterComponent],
providers: [
-----------
],
bootstrap: [JhiMainComponent]
})
...........


The DataService:



export interface Person {
id: string;
isActive: boolean;
age: number;
name: string;
gender: string;
company: string;
email: string;
phone: string;
disabled?: boolean;
}
@Injectable({ providedIn: 'root' })
export class DataService {
.......

constructor(private http: HttpClient) {}
........

getPeople(term: string = null): Observable<Person> {
let items = getMockPeople();
if (term) {
items = items.filter(x => x.name.toLocaleLowerCase().indexOf(term.toLocaleLowerCase()) > -1);
}
return of(items).pipe(delay(500));
}

}

function getMockPeople() {
return [
{
'id': '5a15b13c36e7a7f00cf0d7cb',
'index': 2,
'isActive': true,
'picture': 'http://placehold.it/32x32',
'age': 23,
'name': 'Karyn Wright',
'gender': 'female',
'company': 'ZOLAR',
'email': 'karynwright@zolar.com',
'phone': '+1 (851) 583-2547'
},
{
'id': '5a15b13c2340978ec3d2c0ea',
'index': 3,
'isActive': false,
'picture': 'http://placehold.it/32x32',
'age': 35,
'name': 'Rochelle Estes',
'disabled': true,
'gender': 'female',
'company': 'EXTRAWEAR',
'email': 'rochelleestes@extrawear.com',
'phone': '+1 (849) 408-2029'
}
];
}


the people component:



    export class PeopleUpdateComponent implements OnInit {
people$3: Observable<any>;
selectedPeople3 = ;

constructor(
private jhiAlertService: JhiAlertService,
private dataService: DataService,
private activatedRoute: ActivatedRoute
) {}

ngOnInit() {
this.isSaving = false;
this.people$3 = this.dataService.getPeople();
}
}


My html code is:



<ng-select
[items]="people$3 | async"
bindLabel="name"
[multiple]="true"
[disabled]="disable"
[(ngModel)]="selectedPeople3">
</ng-select>


Any help is appreciated







angular6 jhipster angular7 angular-ngselect






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 10:03







kabisko

















asked Nov 24 '18 at 19:25









kabiskokabisko

134




134








  • 2





    Other users will be able to provide better assistance if you post your present code, what is presently happening and your intended output.

    – Simon.S.A.
    Nov 24 '18 at 19:31














  • 2





    Other users will be able to provide better assistance if you post your present code, what is presently happening and your intended output.

    – Simon.S.A.
    Nov 24 '18 at 19:31








2




2





Other users will be able to provide better assistance if you post your present code, what is presently happening and your intended output.

– Simon.S.A.
Nov 24 '18 at 19:31





Other users will be able to provide better assistance if you post your present code, what is presently happening and your intended output.

– Simon.S.A.
Nov 24 '18 at 19:31












1 Answer
1






active

oldest

votes


















0














I had the same issue as you and I solved it.


This is not an issue related to <ng-select>, but to any library you want to use.

To be able to add any thrid party library, you should follow the way jhipster is doing.

1- Create a module where to add the libraries module in import and export sections

2- Add this module (in import and export sections) to the shared.module.ts module.



A good example is here: https://medium.com/@cyril.casaucau/how-to-add-angular-material-on-an-jhipster-5-x-app-97c9569c9f97



Or simply add the NgSelectModule module to shared-libs.module.ts file.






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53461632%2fjhipster-and-angular-ng-select-component%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I had the same issue as you and I solved it.


    This is not an issue related to <ng-select>, but to any library you want to use.

    To be able to add any thrid party library, you should follow the way jhipster is doing.

    1- Create a module where to add the libraries module in import and export sections

    2- Add this module (in import and export sections) to the shared.module.ts module.



    A good example is here: https://medium.com/@cyril.casaucau/how-to-add-angular-material-on-an-jhipster-5-x-app-97c9569c9f97



    Or simply add the NgSelectModule module to shared-libs.module.ts file.






    share|improve this answer






























      0














      I had the same issue as you and I solved it.


      This is not an issue related to <ng-select>, but to any library you want to use.

      To be able to add any thrid party library, you should follow the way jhipster is doing.

      1- Create a module where to add the libraries module in import and export sections

      2- Add this module (in import and export sections) to the shared.module.ts module.



      A good example is here: https://medium.com/@cyril.casaucau/how-to-add-angular-material-on-an-jhipster-5-x-app-97c9569c9f97



      Or simply add the NgSelectModule module to shared-libs.module.ts file.






      share|improve this answer




























        0












        0








        0







        I had the same issue as you and I solved it.


        This is not an issue related to <ng-select>, but to any library you want to use.

        To be able to add any thrid party library, you should follow the way jhipster is doing.

        1- Create a module where to add the libraries module in import and export sections

        2- Add this module (in import and export sections) to the shared.module.ts module.



        A good example is here: https://medium.com/@cyril.casaucau/how-to-add-angular-material-on-an-jhipster-5-x-app-97c9569c9f97



        Or simply add the NgSelectModule module to shared-libs.module.ts file.






        share|improve this answer















        I had the same issue as you and I solved it.


        This is not an issue related to <ng-select>, but to any library you want to use.

        To be able to add any thrid party library, you should follow the way jhipster is doing.

        1- Create a module where to add the libraries module in import and export sections

        2- Add this module (in import and export sections) to the shared.module.ts module.



        A good example is here: https://medium.com/@cyril.casaucau/how-to-add-angular-material-on-an-jhipster-5-x-app-97c9569c9f97



        Or simply add the NgSelectModule module to shared-libs.module.ts file.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 23 at 13:03

























        answered Jan 23 at 11:44









        Saber ChebkaSaber Chebka

        113




        113
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53461632%2fjhipster-and-angular-ng-select-component%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Costa Masnaga

            Fotorealismo

            Sidney Franklin