【问题标题】:Angular 2 - ngFor with ContentProjection [duplicate]Angular 2 - 带有 ContentProjection 的 ngFor [重复]
【发布时间】:2017-04-26 15:11:56
【问题描述】:

是否可以将 *ngFor 指令与内容投影结合使用?

例如: ...

@Component({
  selector: 'test',
  template: `
    <div>
      <ng-content *ngFor="..."></ng-content> // <-- Phantasy example
    </div>
  `
})
export class TestComponent {
}

...

<test>
    <p>Hello World</p>
</test>

...

所以编译后 DOM 中的结果可能如下所示:

<test>
   <p>Hello World</p>
   <p>Hello World</p>
   <p>Hello World</p>
</test>

【问题讨论】:

标签: angular directive projection ngfor


【解决方案1】:

我认为目前不支持此功能,因为 ng-content 在编译时解析。

看到这个问题:#8563

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-14
    • 1970-01-01
    • 2017-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-20
    • 2018-03-23
    相关资源
    最近更新 更多