Grouping multiple items together after a ngFor
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
add a comment |
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
Though the question relates to a template and data, we're missingupdateData
.
– stealththeninja
Nov 18 '18 at 3:01
@stealththeninja thanks, i've added that to my question
– acctman
Nov 18 '18 at 4:21
add a comment |
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
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
angular
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 missingupdateData
.
– stealththeninja
Nov 18 '18 at 3:01
@stealththeninja thanks, i've added that to my question
– acctman
Nov 18 '18 at 4:21
add a comment |
Though the question relates to a template and data, we're missingupdateData
.
– 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
add a comment |
1 Answer
1
active
oldest
votes
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?
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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?
add a comment |
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?
add a comment |
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?
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?
answered Nov 18 '18 at 3:00
DipackDipack
1135
1135
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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