HeyWeGo
V2EX  ›  Angular

angular 2-4 , ng-template 递归怎么写好?主要是问题在于 ng-template 的属性怎么识别?

  •  
  •   HeyWeGo · Oct 9, 2017 · 4356 views
    This topic created in 3171 days ago, the information mentioned may be changed or developed.

    简单看了下 angular4 的入门教学,其中想实现一个树形结构,用自定义的标签 结构太丑了,怎么用 ng-template 实现?

    自定义的组件递归出来,结构如下:

    <folder-tree-branch>
      <ul>
        <li>
          <a></a>
          <folder-tree-branch>
            <ul>
              <li>
                <a></a>
              </li>
            </ul>
          </folder-tree-branch>
        </li>
      </ul>
    </folder-tree-branch>
    

    自定义标签

    我希望能得到如下结构

    <folder-tree-branch>
      <ul>
        <li>
          <a></a>
            <ul>
              <li>
                <a></a>
              </li>
            </ul>
        </li>
      </ul>
    </folder-tree-branch>
    

    ng-template 报错

    用 ng-template 在递归的时候进入内层之后就报错了,children 属性貌似识别不了了。怎么弄?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1399 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 17:06 · PVG 01:06 · LAX 10:06 · JFK 13:06
    ♥ Do have faith in what you're doing.