小编Chr*_*nik的帖子

Angular2:传递给子组件的ng-content属性

这样的事情可能吗?

我想将一个"hasfocus"变量从cjc-box传递到ng-content属性到cjc-input组件.

app.component.html

<div cjc-box><div cjc-input></div></div>
Run Code Online (Sandbox Code Playgroud)

CIC-box.component.html

<div class="cjc-box">
  <div><ng-content hasfocus="focus"></ng-content></div>
</div>
Run Code Online (Sandbox Code Playgroud)

CIC-input.component.html

<input class="cjc-input" type="text" focus="{{hasfocus}}" />
Run Code Online (Sandbox Code Playgroud)

这对于ng2中的预测是否可能?

projection parameter-passing angular

9
推荐指数
1
解决办法
6647
查看次数

标签 统计

angular ×1

parameter-passing ×1

projection ×1