2017-04-04 17 views
0

ng-includeとng-template(以下に示す)で再帰的に印刷しようとすると、以下のようなjsonsデータがあります。それは空白です。 と他の問題は、ng-includeを印刷すると、1レベルの再帰を印刷するだけで印刷を続行しないということです。htmlはng-templateでレンダリングされていません

何が問題なのですか?

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を使用して、ブレードシステムの印刷のために、私は{{}}角度プリントシンボルを交換しました<%>

+1

JSONを変更したり、ngのリピートを変更する必要が ''構文 – PaladiN

答えて

0

私はあなたが別のコードを使用する必要があると思います。あなたのjsonはフォルダのツリーを表しますが、角型アプリケーションでは、最初のレベルのみを反復しており、最初のレベルではsubdirを持つアイテムは1つしかありません。

json応答を正しくフォーマットすると、これを簡単に理解できます。 `{{}}の角度を変更する必要はありません

[ 
    { 
    "name":"default", 
    "path":">var>www>rapa-v2>themes>", 
    "subdir": 
     [ 
     { 
      ******** You're targeting this element below ********** 
      "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" 
         } 
        ] 
     }, 
     { 
     ******** This doesn't has subdir ********** 
      "name":"index.blade.php", 
      "path":">var>www>rapa-v2>themes>>default" 
     }, 
     { 
     ******** This doesn't has subdir **********    
      "name":"information.json", 
      "path":">var>www>rapa-v2>themes>>default" 
     }, 
     { 
     ******** This doesn't has subdir ********** 
      "name":"screen.jpg", 
      "path":">var>www>rapa-v2>themes>>default" 
     } 
     ] 
    } 
] 

ですから、あなたが` @ {{}} Laravelを使用することができます

+0

サブディレクトリプロパティでフォルダとファイルを分離しようとしましたが、json形式の提案は何ですか? – Abolfazl

+0

私はまだ問題があります。 – Abolfazl

関連する問題