小编lev*_*vis的帖子

Angular2 Smart Tables - 将数据传递给自定义组件

我正在使用 Angular2 并且我正在尝试为我的Smart Table 中的每一行添加一个视图链接。我正在使用允许我呈现自定义组件的自定义类型来执行此操作。

渲染过程运行良好,但现在我需要将数据(项目的 id)传递给自定义组件,但我不知道数据是如何发送到模板的,因此我无法访问它。

这是我的表组件:

export class ShowLoans {
  query: string = '';

  settings = {
    actions: {
      delete: false,
      add: false
    },
   columns: {
   //...
      actions: {
        title: 'Acciones',
        type: 'custom',
        renderComponent: ViewLoan
      }
    }
  };

  source: LocalDataSource = new LocalDataSource();

  constructor(protected  loanService: LoanService) {
    this.loanService.getAllLoans().subscribe((data) => {
      this.source.load(data.loans);
    });
  }
Run Code Online (Sandbox Code Playgroud)

这是我的自定义组件:

@Component({
  selector: 'viewloan',
  templateUrl: './viewLoan.html'
})
export class ViewLoan {

  public loan: Loan;
  constructor(){

  }
}
Run Code Online (Sandbox Code Playgroud)

**注意:ViewLoan 组件被声明为 entryComponent。

ng2-smart-table angular

3
推荐指数
1
解决办法
6115
查看次数

标签 统计

angular ×1

ng2-smart-table ×1