Working with mongoDB's $filter aggregation currently, and it has been able to produce me the expected output from my query. The problem lies within my HTML whereas *ngFor does not display my data nor does it show any error within the console.
For a better understanding, this is my JSON produced from a console.log:
Below is my query code:
//api.js
router.get('/agent-policies/:name', (req, res) => {
db.collection('users').aggregate([
// Get just the docs that contain an agent element where agent is === req.params.name
{$match: {'paPolicies.policy.agent': req.params.name}},
{$project: {
policy: {$filter: {
input: '$paPolicies.policy',
as: 'police',
cond: {$eq: ['$$police.agent', req.params.name]}
}},
_id: 0
}}
]).toArray((err, results) => {
if (err) throw err;
res.send(results);
})
})
And lastly, my template code:
//component.html
<div *ngFor='let police of agentPolicies'>
{{police.relationship}}
</div>
where agentPolicies has been set as an array in my component.ts as:
agentPolicies: any = [];
Since the code is not producing any error, I would assume that the problem is within my HTML and I am not using *ngFor correctly. What do I change in order to display the value of relationship from my JSON?
