Angular6 如何更新ng2智能表';什么是自定义零件?
在我的angular 6应用程序中,我使用了ng2智能表。现在,我需要根据自定义操作功能的访问权限显示和隐藏它们 我能够管理添加、edir和删除部分。随着这一点,我也把一些自定义图标也额外的功能Angular6 如何更新ng2智能表';什么是自定义零件?,angular6,ng2-smart-table,Angular6,Ng2 Smart Table,在我的angular 6应用程序中,我使用了ng2智能表。现在,我需要根据自定义操作功能的访问权限显示和隐藏它们 我能够管理添加、edir和删除部分。随着这一点,我也把一些自定义图标也额外的功能 custom: [ { name: 'up', title: '<img src="/pathOfIcon" class="tableIcon up-arrow-true-icon">' }, { name: 'up-cancel', title: '<
custom: [
{ name: 'up', title: '<img src="/pathOfIcon" class="tableIcon up-arrow-true-icon">' },
{ name: 'up-cancel', title: '<img src="/pathOfIcon" class="tableIcon up-arrow-cancel-icon">' },
{ name: 'down', title: '<img src="/pathOfIcon" class="tableIcon down-arrow-true-icon">' },
{ name: 'down-cancel', title: '<img src="/pathOfIcon" class="tableIcon down-arrow-cancel-icon">' },
]
自定义:[
{名称:'up',标题:'},
{name:'up cancel',title:'},
{名称:'down',标题:'},
{name:'向下取消',标题:'},
]
现在我需要基于访问权限来管理这件事
那么我如何启用和禁用这些图标呢
注意:我可以在每一行上应用css,然后隐藏图标,但我需要在每一行上做一次 您可以在自定义数组中添加图标的同时添加图标 这样试试
if(access){ // Set you access condition
this.settings.custom.push('{ name: 'up', title: '<img src="/pathOfIcon" class="tableIcon up-arrow-true-icon">' }');
this.settings.custom.push('{ name: 'up-cancel', title: '<img src="/pathOfIcon" class="tableIcon up-arrow-cancel-icon">' },');
}else{
this.settings.custom.push(' { name: 'down', title: '<img src="/pathOfIcon" class="tableIcon down-arrow-true-icon">' }');
this.settings.custom.push('{ name: 'down-cancel', title: '<img src="/pathOfIcon" class="tableIcon down-arrow-cancel-icon">' }');
}
if(access){//设置访问条件
this.settings.custom.push('{name:'up',title:'}');
this.settings.custom.push('{name:'up cancel',title:'}');
}否则{
this.settings.custom.push('{name:'down',title:'}');
this.settings.custom.push('{name:'down cancel',title:'}');
}
这是添加图标的简单方法。。。因为自定义
是数组,所以您可以在其中推送图标
希望这能帮助你……:)