angularjs - angularjs用组件将祖父母传给孙子
问题描述
如果可以的话,让我举一个例子:
<grandparent>
<parent>
<grandson>
如果祖父母有一个对象,让我们说一个人
const person = {
name: 'William',
age: 102
}
孙子如何能够从祖父母那里继承这种价值?
<title={{ $ctrl.person.name }}>
不会工作,因为这$ctrl
将是父母。
希望我的轻松例子也能如此。
解决方案
这是更新的代码:
<grand-parent>
<cbs-cus-comp com-bind='grandParentCntAs.name'>
<child child-com-bind='cbsCusCompCntAs.name'></child>
</cbs-cus-comp>
</grand-parent>
您需要提供以下内容才能实现这一目标:
var cbsCusComp = {
transclude : true,
require: {grandParentComp:'^grandParent'},
template : 'Parent : <b>{{cbsCusCompCntAs.comBind}}</b><br /><ng-transclude></ng-transclude>',
controller : cbsCusCompCnt,
controllerAs: 'cbsCusCompCntAs',
bindings : {comBind:'='}
};
推荐阅读
- javascript - 如何将相机移回画布上
- c# - 在写入所有字节之前无法关闭流c#
- c - 一个守护进程的父进程是否应该在分叉其子进程后释放()内存?
- shadow-dom - 如何将选项标签作为分布式节点传递给自定义元素(又名
) - math - 如何在 SDF 函数中获取点的世界空间坐标?
- lisp - 如何使用 cl-async 在 Lisp 中检索套接字对等点的地址
- macos - 如何在 MacOS 上的 Araxis Merge 中更改字体大小以放大和缩小?
- java - 规格 Spring Boot
- excel - 如何动态自动填充单元格
- python - 将列中的字符串十进制数字转换为在 Pandas DataFrame 中浮动