How to load dynamic data using node package “ng-multiselect-dropdown”












0















In Angular(6) project, I am using a node package named ng-multiselect-dropdown for a dropdown input field. I am facing difficulty
to load dynamic data in a dropdown list. Is there any way to load dynamic data while using ng-multiselect-dropdown or Is there any
similar node package which provided the same functionality of ng-multiselect-dropdown.



Thank you.



<ng-multiselect-dropdown [data]="userDropdownList" 
[(ngModel)]="selectedItems" [settings]="dropdownSettings"
(onSelect)="onItemSelect($event)"
(onSelectAll)="onSelectAll($event)">
</ng-multiselect-dropdown>


userDropdownList = ;
ngOnInit() {
this.departmentService.getUsers(this.authService.getUser().client_id)
.subscribe((response: any) => {
for (let data of response.data) {
this.userDropdownList.push({ '_id': data._id,
'name': data.firstname + ' ' + data.lastname })
}
},
error => {
console.log("error :", error);
})
}









share|improve this question























  • What’s the issue, is service working fine ?

    – super cool
    Jan 1 at 16:11











  • Service is working fine. The data I am getting from the HTTP request is not showing in dropdown list.

    – Md. Amanullah
    Jan 1 at 16:20











  • If I declare static array of object like below code, then it works. But from http request , it is not working: this.userDropdownList = [ { _id: "5ae89f362c6f957fe0ddf173", name: "Raja Khan" }, { _id: "5ae96638dbceb53af3344d1b", name: "Ubaid Showkat" }, { _id: "5afd5ec12e275b636bbda827", name: "Keninteiten Daz" }, { _id: "5b2b752ddd444f78c3f775c5", name: "Calvin Shehryar" }, { _id: "5b2c993116e48626a589ab70", name: "test s" } ];

    – Md. Amanullah
    Jan 1 at 16:26













  • code looks fine, did you try declaring the same static thing inside .subscribe((response: any) => { ?

    – super cool
    Jan 2 at 4:13











  • Yes. I declared the same variable.

    – Md. Amanullah
    Jan 2 at 6:52
















0















In Angular(6) project, I am using a node package named ng-multiselect-dropdown for a dropdown input field. I am facing difficulty
to load dynamic data in a dropdown list. Is there any way to load dynamic data while using ng-multiselect-dropdown or Is there any
similar node package which provided the same functionality of ng-multiselect-dropdown.



Thank you.



<ng-multiselect-dropdown [data]="userDropdownList" 
[(ngModel)]="selectedItems" [settings]="dropdownSettings"
(onSelect)="onItemSelect($event)"
(onSelectAll)="onSelectAll($event)">
</ng-multiselect-dropdown>


userDropdownList = ;
ngOnInit() {
this.departmentService.getUsers(this.authService.getUser().client_id)
.subscribe((response: any) => {
for (let data of response.data) {
this.userDropdownList.push({ '_id': data._id,
'name': data.firstname + ' ' + data.lastname })
}
},
error => {
console.log("error :", error);
})
}









share|improve this question























  • What’s the issue, is service working fine ?

    – super cool
    Jan 1 at 16:11











  • Service is working fine. The data I am getting from the HTTP request is not showing in dropdown list.

    – Md. Amanullah
    Jan 1 at 16:20











  • If I declare static array of object like below code, then it works. But from http request , it is not working: this.userDropdownList = [ { _id: "5ae89f362c6f957fe0ddf173", name: "Raja Khan" }, { _id: "5ae96638dbceb53af3344d1b", name: "Ubaid Showkat" }, { _id: "5afd5ec12e275b636bbda827", name: "Keninteiten Daz" }, { _id: "5b2b752ddd444f78c3f775c5", name: "Calvin Shehryar" }, { _id: "5b2c993116e48626a589ab70", name: "test s" } ];

    – Md. Amanullah
    Jan 1 at 16:26













  • code looks fine, did you try declaring the same static thing inside .subscribe((response: any) => { ?

    – super cool
    Jan 2 at 4:13











  • Yes. I declared the same variable.

    – Md. Amanullah
    Jan 2 at 6:52














0












0








0








In Angular(6) project, I am using a node package named ng-multiselect-dropdown for a dropdown input field. I am facing difficulty
to load dynamic data in a dropdown list. Is there any way to load dynamic data while using ng-multiselect-dropdown or Is there any
similar node package which provided the same functionality of ng-multiselect-dropdown.



Thank you.



<ng-multiselect-dropdown [data]="userDropdownList" 
[(ngModel)]="selectedItems" [settings]="dropdownSettings"
(onSelect)="onItemSelect($event)"
(onSelectAll)="onSelectAll($event)">
</ng-multiselect-dropdown>


userDropdownList = ;
ngOnInit() {
this.departmentService.getUsers(this.authService.getUser().client_id)
.subscribe((response: any) => {
for (let data of response.data) {
this.userDropdownList.push({ '_id': data._id,
'name': data.firstname + ' ' + data.lastname })
}
},
error => {
console.log("error :", error);
})
}









share|improve this question














In Angular(6) project, I am using a node package named ng-multiselect-dropdown for a dropdown input field. I am facing difficulty
to load dynamic data in a dropdown list. Is there any way to load dynamic data while using ng-multiselect-dropdown or Is there any
similar node package which provided the same functionality of ng-multiselect-dropdown.



Thank you.



<ng-multiselect-dropdown [data]="userDropdownList" 
[(ngModel)]="selectedItems" [settings]="dropdownSettings"
(onSelect)="onItemSelect($event)"
(onSelectAll)="onSelectAll($event)">
</ng-multiselect-dropdown>


userDropdownList = ;
ngOnInit() {
this.departmentService.getUsers(this.authService.getUser().client_id)
.subscribe((response: any) => {
for (let data of response.data) {
this.userDropdownList.push({ '_id': data._id,
'name': data.firstname + ' ' + data.lastname })
}
},
error => {
console.log("error :", error);
})
}






angular angular6






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 1 at 15:55









Md. AmanullahMd. Amanullah

217




217













  • What’s the issue, is service working fine ?

    – super cool
    Jan 1 at 16:11











  • Service is working fine. The data I am getting from the HTTP request is not showing in dropdown list.

    – Md. Amanullah
    Jan 1 at 16:20











  • If I declare static array of object like below code, then it works. But from http request , it is not working: this.userDropdownList = [ { _id: "5ae89f362c6f957fe0ddf173", name: "Raja Khan" }, { _id: "5ae96638dbceb53af3344d1b", name: "Ubaid Showkat" }, { _id: "5afd5ec12e275b636bbda827", name: "Keninteiten Daz" }, { _id: "5b2b752ddd444f78c3f775c5", name: "Calvin Shehryar" }, { _id: "5b2c993116e48626a589ab70", name: "test s" } ];

    – Md. Amanullah
    Jan 1 at 16:26













  • code looks fine, did you try declaring the same static thing inside .subscribe((response: any) => { ?

    – super cool
    Jan 2 at 4:13











  • Yes. I declared the same variable.

    – Md. Amanullah
    Jan 2 at 6:52



















  • What’s the issue, is service working fine ?

    – super cool
    Jan 1 at 16:11











  • Service is working fine. The data I am getting from the HTTP request is not showing in dropdown list.

    – Md. Amanullah
    Jan 1 at 16:20











  • If I declare static array of object like below code, then it works. But from http request , it is not working: this.userDropdownList = [ { _id: "5ae89f362c6f957fe0ddf173", name: "Raja Khan" }, { _id: "5ae96638dbceb53af3344d1b", name: "Ubaid Showkat" }, { _id: "5afd5ec12e275b636bbda827", name: "Keninteiten Daz" }, { _id: "5b2b752ddd444f78c3f775c5", name: "Calvin Shehryar" }, { _id: "5b2c993116e48626a589ab70", name: "test s" } ];

    – Md. Amanullah
    Jan 1 at 16:26













  • code looks fine, did you try declaring the same static thing inside .subscribe((response: any) => { ?

    – super cool
    Jan 2 at 4:13











  • Yes. I declared the same variable.

    – Md. Amanullah
    Jan 2 at 6:52

















What’s the issue, is service working fine ?

– super cool
Jan 1 at 16:11





What’s the issue, is service working fine ?

– super cool
Jan 1 at 16:11













Service is working fine. The data I am getting from the HTTP request is not showing in dropdown list.

– Md. Amanullah
Jan 1 at 16:20





Service is working fine. The data I am getting from the HTTP request is not showing in dropdown list.

– Md. Amanullah
Jan 1 at 16:20













If I declare static array of object like below code, then it works. But from http request , it is not working: this.userDropdownList = [ { _id: "5ae89f362c6f957fe0ddf173", name: "Raja Khan" }, { _id: "5ae96638dbceb53af3344d1b", name: "Ubaid Showkat" }, { _id: "5afd5ec12e275b636bbda827", name: "Keninteiten Daz" }, { _id: "5b2b752ddd444f78c3f775c5", name: "Calvin Shehryar" }, { _id: "5b2c993116e48626a589ab70", name: "test s" } ];

– Md. Amanullah
Jan 1 at 16:26







If I declare static array of object like below code, then it works. But from http request , it is not working: this.userDropdownList = [ { _id: "5ae89f362c6f957fe0ddf173", name: "Raja Khan" }, { _id: "5ae96638dbceb53af3344d1b", name: "Ubaid Showkat" }, { _id: "5afd5ec12e275b636bbda827", name: "Keninteiten Daz" }, { _id: "5b2b752ddd444f78c3f775c5", name: "Calvin Shehryar" }, { _id: "5b2c993116e48626a589ab70", name: "test s" } ];

– Md. Amanullah
Jan 1 at 16:26















code looks fine, did you try declaring the same static thing inside .subscribe((response: any) => { ?

– super cool
Jan 2 at 4:13





code looks fine, did you try declaring the same static thing inside .subscribe((response: any) => { ?

– super cool
Jan 2 at 4:13













Yes. I declared the same variable.

– Md. Amanullah
Jan 2 at 6:52





Yes. I declared the same variable.

– Md. Amanullah
Jan 2 at 6:52












0






active

oldest

votes











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%2f53996848%2fhow-to-load-dynamic-data-using-node-package-ng-multiselect-dropdown%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















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%2f53996848%2fhow-to-load-dynamic-data-using-node-package-ng-multiselect-dropdown%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

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

Npm cannot find a required file even through it is in the searched directory