Grouping multiple items together after a ngFor












0















Currently I have a ng-template that outputs items from an array. I am have trouble trying to group the key_id and key_name together as a set



i.e. ( key_id = 1, key_name = hello1 ) , ( key_id = 2, key_name = hello2 )... Now when I pass the values via updateDate the output should be hello1:1, hello2:2



<ng-template ngFor let-key [ngForOf]="item['data']['keys']">

<a class="text-success" title="Edit Menu"
(click)="updateData(item['data']['title'],
item['data']['url'],key['tag_id'],key['key_name'],false)">

<i class="text-success fa fa-edit toogleIcon"></i>

</a>

</ng-template>


the JSON



"data": [
{
"data": {
"id": "1",
"title": "Location",
"url": "location",
"keys": [
{
"key_id": "1",
"key_name": "DefaultLine"
},
{
"key_id": "4",
"key_name": "Mainline"
}


TS for UpdateData



private updateData(title: any, url: any, key_id: any, key_name: any, flag: boolean) {
console.log('title=>', title);
console.log('url=>', url);
console.log('key_name=>', key_name);
console.log('key_id=>', key_id);
this.title = title;
url === null ? this.url = "" : this.url = url;
key_id === null ? this.key_id = "" : this.key_id = key_id;
key_name === null ? this.key_name = "" : this.key_name = key_name;
}









share|improve this question

























  • Though the question relates to a template and data, we're missing updateData.

    – stealththeninja
    Nov 18 '18 at 3:01











  • @stealththeninja thanks, i've added that to my question

    – acctman
    Nov 18 '18 at 4:21
















0















Currently I have a ng-template that outputs items from an array. I am have trouble trying to group the key_id and key_name together as a set



i.e. ( key_id = 1, key_name = hello1 ) , ( key_id = 2, key_name = hello2 )... Now when I pass the values via updateDate the output should be hello1:1, hello2:2



<ng-template ngFor let-key [ngForOf]="item['data']['keys']">

<a class="text-success" title="Edit Menu"
(click)="updateData(item['data']['title'],
item['data']['url'],key['tag_id'],key['key_name'],false)">

<i class="text-success fa fa-edit toogleIcon"></i>

</a>

</ng-template>


the JSON



"data": [
{
"data": {
"id": "1",
"title": "Location",
"url": "location",
"keys": [
{
"key_id": "1",
"key_name": "DefaultLine"
},
{
"key_id": "4",
"key_name": "Mainline"
}


TS for UpdateData



private updateData(title: any, url: any, key_id: any, key_name: any, flag: boolean) {
console.log('title=>', title);
console.log('url=>', url);
console.log('key_name=>', key_name);
console.log('key_id=>', key_id);
this.title = title;
url === null ? this.url = "" : this.url = url;
key_id === null ? this.key_id = "" : this.key_id = key_id;
key_name === null ? this.key_name = "" : this.key_name = key_name;
}









share|improve this question

























  • Though the question relates to a template and data, we're missing updateData.

    – stealththeninja
    Nov 18 '18 at 3:01











  • @stealththeninja thanks, i've added that to my question

    – acctman
    Nov 18 '18 at 4:21














0












0








0








Currently I have a ng-template that outputs items from an array. I am have trouble trying to group the key_id and key_name together as a set



i.e. ( key_id = 1, key_name = hello1 ) , ( key_id = 2, key_name = hello2 )... Now when I pass the values via updateDate the output should be hello1:1, hello2:2



<ng-template ngFor let-key [ngForOf]="item['data']['keys']">

<a class="text-success" title="Edit Menu"
(click)="updateData(item['data']['title'],
item['data']['url'],key['tag_id'],key['key_name'],false)">

<i class="text-success fa fa-edit toogleIcon"></i>

</a>

</ng-template>


the JSON



"data": [
{
"data": {
"id": "1",
"title": "Location",
"url": "location",
"keys": [
{
"key_id": "1",
"key_name": "DefaultLine"
},
{
"key_id": "4",
"key_name": "Mainline"
}


TS for UpdateData



private updateData(title: any, url: any, key_id: any, key_name: any, flag: boolean) {
console.log('title=>', title);
console.log('url=>', url);
console.log('key_name=>', key_name);
console.log('key_id=>', key_id);
this.title = title;
url === null ? this.url = "" : this.url = url;
key_id === null ? this.key_id = "" : this.key_id = key_id;
key_name === null ? this.key_name = "" : this.key_name = key_name;
}









share|improve this question
















Currently I have a ng-template that outputs items from an array. I am have trouble trying to group the key_id and key_name together as a set



i.e. ( key_id = 1, key_name = hello1 ) , ( key_id = 2, key_name = hello2 )... Now when I pass the values via updateDate the output should be hello1:1, hello2:2



<ng-template ngFor let-key [ngForOf]="item['data']['keys']">

<a class="text-success" title="Edit Menu"
(click)="updateData(item['data']['title'],
item['data']['url'],key['tag_id'],key['key_name'],false)">

<i class="text-success fa fa-edit toogleIcon"></i>

</a>

</ng-template>


the JSON



"data": [
{
"data": {
"id": "1",
"title": "Location",
"url": "location",
"keys": [
{
"key_id": "1",
"key_name": "DefaultLine"
},
{
"key_id": "4",
"key_name": "Mainline"
}


TS for UpdateData



private updateData(title: any, url: any, key_id: any, key_name: any, flag: boolean) {
console.log('title=>', title);
console.log('url=>', url);
console.log('key_name=>', key_name);
console.log('key_id=>', key_id);
this.title = title;
url === null ? this.url = "" : this.url = url;
key_id === null ? this.key_id = "" : this.key_id = key_id;
key_name === null ? this.key_name = "" : this.key_name = key_name;
}






angular






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 18 '18 at 4:18







acctman

















asked Nov 18 '18 at 2:44









acctmanacctman

2,0632479121




2,0632479121













  • Though the question relates to a template and data, we're missing updateData.

    – stealththeninja
    Nov 18 '18 at 3:01











  • @stealththeninja thanks, i've added that to my question

    – acctman
    Nov 18 '18 at 4:21



















  • Though the question relates to a template and data, we're missing updateData.

    – stealththeninja
    Nov 18 '18 at 3:01











  • @stealththeninja thanks, i've added that to my question

    – acctman
    Nov 18 '18 at 4:21

















Though the question relates to a template and data, we're missing updateData.

– stealththeninja
Nov 18 '18 at 3:01





Though the question relates to a template and data, we're missing updateData.

– stealththeninja
Nov 18 '18 at 3:01













@stealththeninja thanks, i've added that to my question

– acctman
Nov 18 '18 at 4:21





@stealththeninja thanks, i've added that to my question

– acctman
Nov 18 '18 at 4:21












1 Answer
1






active

oldest

votes


















2














In the updateData function call in the a element, the third parameter looks for the tag_id property. From what I can make of your JSON, it should be looking for the key_id parameter. Maybe that's it?






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%2f53357436%2fgrouping-multiple-items-together-after-a-ngfor%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









    2














    In the updateData function call in the a element, the third parameter looks for the tag_id property. From what I can make of your JSON, it should be looking for the key_id parameter. Maybe that's it?






    share|improve this answer




























      2














      In the updateData function call in the a element, the third parameter looks for the tag_id property. From what I can make of your JSON, it should be looking for the key_id parameter. Maybe that's it?






      share|improve this answer


























        2












        2








        2







        In the updateData function call in the a element, the third parameter looks for the tag_id property. From what I can make of your JSON, it should be looking for the key_id parameter. Maybe that's it?






        share|improve this answer













        In the updateData function call in the a element, the third parameter looks for the tag_id property. From what I can make of your JSON, it should be looking for the key_id parameter. Maybe that's it?







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 18 '18 at 3:00









        DipackDipack

        1135




        1135






























            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%2f53357436%2fgrouping-multiple-items-together-after-a-ngfor%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

            Guess what letter conforming each word

            Port of Spain

            Run scheduled task as local user group (not BUILTIN)