【发布时间】:2025-12-17 21:35:01
【问题描述】:
我有一些 jsons 数据,如下所示,当我尝试使用 ng-include 和 ng-template 递归打印它们时(如下所示),ng-include 的内部 html 代码没有呈现并且它是空白的。 另一个问题是在打印 ng-include 时,它只打印 1 级递归并且它不会继续打印。
那怎么了?
Json 数据:
[{"name":"default","path":">var>www>rapa-v2>themes>","subdir":[{"name":"css","path":" >var>www>rapa-v2>themes>>default","subdir":[{"name":"images","path":">var>www>rapa-v2>themes>>default>css" ,"subdir":[]},{"name":"style.css","path":">var>www>rapa-v2>themes>>default>css"}]},{"name": "index.blade.php","path":">var>www>rapa-v2>themes>>default"},{"name":"information.json","path":">var>www> rapa-v2>themes>>default"},{"name":"screen.jpg","path":">var>www>rapa-v2>themes>>default"}]}]
HTML代码:
<div class="theme-files-list ltr" ng-init="loadDir('{{ $theme }}')">
<script type="text/ng-template" id="directoryTree">
<div class="tree-item">
<i class="fa fa-file-text-o maroon"></i>
<a href="<% '/admin/setting/template/edit/{{ $theme }}/'+item.name %>">
<% item.name %>
</a>
</div>
<ul ng-if="item.subdir">
<li ng-repeat="item in item.subdir" ng-include="'directoryTree'"></li>
</ul>
</script>
<ul class="noselect">
<li>
<div class="tree-item bg-aqua">
<i class="fa fa-paint-brush blue"></i>
{{ ucfirst($theme) }}
</div>
<ul>
<li ng-repeat="item in themeDir" ng-include="'directoryTree'"></li>
</ul>
</li>
</ul>
</div>
重要:我使用 laravel 并且对于刀片系统打印,我已将角打印符号 {{ }} 替换为
【问题讨论】:
-
你可以使用 Laravel
@{{ }},不需要你改变 angular{{ }}语法
标签: angularjs json laravel recursion angularjs-ng-include