Return data from another

Asked

Viewed 38 times

0

I have the following problem, create the user and add the same in a course. Only I can’t return the course name on the user page. The course is added via select input, sending only the course ID. When I turn around I see

{{user.curso}}

It returns _id: "5b38e3bc9dbf9113560a2d4c".

I tried to create a pipe and filter it by the user.curso, but it didn’t work either. It didn’t return any information.

@Pipe({
    name: "filter",
    pure: false
})
export class ArrayFilterPipe implements PipeTransform {
 
    transform(items: Array<any>, conditions: {[field: string]: any}): Array<any> {
        return items.filter(item => {
            for (let field in conditions) {
                if (item[field] !== conditions[field]) {
                    return false;
                }
            }
            return true;
        });
    }
}

<div class="content" *ngFor="let curso of cursos | filter:{user:user.curso}">
<li>{{curso.title}}</li>
  </div>

Can someone give me a hint?

  • Can you post the code of your select? By your question you are using a div instead of a select.

  • Be able to solve and the right way working in the backend, I used aggegate with $lookup and I was able to solve.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.