0

I'm trying to get selected data from the component nb-select and pass it to ng2 smart table , after implementing the code below the nb-select diplayed correctly in the cell of the table also I can see the the data selected but in nb-list Component not where I want I hope explained well my problem, sorry for my english , I'm stuck since one week
nb-list.html :

<nb-select
  [(ngModel)]="selectedlist"
  multiple
  placeholder="Liste TPE disponible"
  (ngModelChange)="change($event)"
>
  <nb-option *ngFor="let tpe of listOfTpeNoneBinded" [value]="tpe.sn">
    {{ tpe.sn }}
  </nb-option>
</nb-select>

nb-list.ts :

import { Component, Input, OnInit } from "@angular/core";
import { Apollo } from "apollo-angular";
import { UserService } from "../user/user.service";

@Component({
  selector: "ngx-nb-list",
  templateUrl: "./nb-list.component.html",
  styleUrls: ["./nb-list.component.scss"],
})
export class NbListComponent implements OnInit {
  listOfTpeNoneBinded;
  selectedlist;
  // @Input() value;
  constructor(private apollo: Apollo, private userService: UserService) {}

  ngOnInit(): void {
    this.getNoBinded();
  }
  change(event) {
    console.log(event);
  }
    
  getNoBinded() {
    this.apollo
      .query<any>({ query: this.userService.getNoBinded() })
      .subscribe(({ data }) => {
        console.log("getNoBindedTPE", data);
        this.listOfTpeNoneBinded = data.getNoBindedTPE;
      });
  }
}

my code in ng2 smart table

bindedSn: {
        title: "bindedSn",
        type: "html",
        editor: {
          type: "custom",
          valuePrepareFunction: (cell, row) => {
            return row;
          },

          // data exists in nb list compoent i want to get the data from nb list component to here
          component: NbListComponent,
        },
      },
Fredrick
  • 37
  • 3
  • Does this answer your question? [How do I pass data to Angular routed components?](https://stackoverflow.com/questions/36835123/how-do-i-pass-data-to-angular-routed-components) – The Fabio Jun 07 '22 at 11:25
  • Usually when you don't have a parent-child relationship between your components or they don't share the same parent and you still want to be able to share data between them, you would use a service to do that. – Octavian Mărculescu Jun 07 '22 at 11:32

0 Answers0