javascript - 不在 jstree 和 Angular 中显示列表
问题描述
我需要使用 Jstree 在 Angular6 中显示所有角色。
我从服务器获取所有列表,但它没有显示我任何东西。
我怎么解决这个问题?
我的代码:
索引中的配置:
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" />
<title>StoreAp</title>
<base href="/">
</head>
<body>
<app-root></app-root>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
</body>
</html>
HTML:
<div class="addRole">
<div id="jstree">
</div>
</div>
<script>
$('#jstree').on('changed.jstree',function(data){
var i,j;
var postItem =[];
j=data.selected.lenght;
for( i=0 ; i<j ; i++ )
{
var id=data.selected[i];
postItem.push({
text:data.instanse.get_node(data.selected[i]).text,
id:id,
parent:data.node.parents[0]
});
}
$('#selectedItems').val(JSON.stringify(postItem));
}).jstree({
"core":{
"theme":{
"variant":"large"
},
"data":subroles
},
"checkbox":{
"keep_selected_style":false
},
"plugin":["wholerow"]
});
</script>
并在 .TS 文件中
export class AccessLevelComponent implements OnInit {
public subroles:Isubrole[];
constructor(private roleService:RoleServiceService) { }
ngOnInit() {
this.roleService.GetSubrole().subscribe((data)=>{
this.subroles=data;
});
}
}
解决方案
推荐阅读
- r - cat 函数中的 R 汇总函数导致问题
- ruby-on-rails - rails 如何获取图像名称而不是神社 url 的哈希
- database - Unity 将游戏统计数据上传到网站
- html - 引导多输入文件
- java - KeychainStore 不向 Mac OS X 上的 Java 提供证书
- android-studio - Genymotion 不适用于 Ubuntu 20.04 LTS for android studio
- java - Hackerearth 感觉更高
- java - 如何使用 JSON-B 序列化循环引用对象(用于 JSON 绑定的 Java API)
- c++ - 创建 mkaes 产品构建并创建调试信息的 C++ Makefile 的最佳方法是什么?
- android - 如何在 Flutter Android 中声明应始终使用最新安装的 ndk 版本?