populate json content in table using angular6

Multi tool use


populate json content in table using angular6
I have json to construct table by populating its header and body dynamically. But my following table angular6 code is not populating as expected. Could anyone suggest the problem is in json or table iteration.
Expected Output:
JSON:
this.columns = ["role1", "role2", "role3"];
this.permission =
[ {
role1: [{
master: { sub1: { read: true, write: true },
sub2: { read: true, write: true } },
support: { sub3: { read: true, write: false } },
admin: { sub4: { read: false, write: false } }
}],
role2: [{
master: { sub1: { read: true, write: false },
sub2: { read: true, write: false } },
support: { sub3: { read: true, write: true } },
admin: { sub4: { read: false, write: false } }
}],
role3: [{
master: { sub1: { read: true, write: true },
sub2: { read: true, write: true } },
admin: { sub4: { read: true, write: true } }
}]
},
{
role1: [{
master: { sub1: { read: true, write: true },
{ sub2: { read: true, write: true }
},
support: {
sub3: { read: true, write: false }
},
admin: {
sub4: { read: false, write: false }
}
}],
role2: [{
master: {
sub1: { read: true, write: false },
sub2: { read: true, write: false }
},
support: {
sub3: { read: true, write: true }
},
admin: {
sub4: { read: false, write: false }
}
}],
role3: [{
master: {
sub1: { read: true, write: true },
sub2: { read: true, write: true }
},
admin: {
sub4: { read: true, write: true }
}
}]
}
]
Output:
1 Answer
1
There are a bunch of errors in your json. You can use JSON lint to validate (although JSON will require you to put keys into double quotes whereas typescript doesnt)
Try again with this for permissions
:
permissions
this.permission =
[ {
role1: [{
master: { sub1: { read: true, write: true },
sub2: { read: true, write: true } },
support: { sub3: { read: true, write: false } },
admin: { sub4: { read: false, write: false } }
}],
role2: [{
master: { sub1: { read: true, write: false },
sub2: { read: true, write: false } },
support: { sub3: { read: true, write: true } },
admin: { sub4: { read: false, write: false } }
}],
role3: [{
master: { sub1: { read: true, write: true },
sub2: { read: true, write: true } },
admin: { sub4: { read: true, write: true } }
}]
},
{
role1: [{
master: {
sub1: { read: true, write: true },
sub2: { read: true, write: true }
},
support: {
sub3: { read: true, write: false }
},
admin: {
sub4: { read: false, write: false }
}
}],
role2: [{
master: {
sub1: { read: true, write: false },
sub2: { read: true, write: false }
},
support: {
sub3: { read: true, write: true }
},
admin: {
sub4: { read: false, write: false }
}
}],
role3: [{
master: {
sub1: { read: true, write: true },
sub2: { read: true, write: true }
},
admin: {
sub4: { read: true, write: true }
}
}]
}
];
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Can you provide the HTML?
– undefinedMayNotBeNull
25 mins ago