【发布时间】:2016-12-20 20:10:40
【问题描述】:
我正在尝试在 Angular 1.5 中实现一个简单的组件,我正在尝试访问组件 mycomponentheader 中的绑定(绑定)属性 'compTitle'。
var mycomponentheader = {
....
bindings: {
'comptitle': '@mycomptitle'
},
....
};
我在视图的 html 标记中传递属性值 [compTitle="encryptedTitle"]。
<mycomponentheader mycomptitle="encryptedTitle">
<div>
This is displayed for component content
</div>
</mycomponentheader>
wnen 我尝试在指令中使用类似的机制。 相同的jsfiddle是@https://jsfiddle.net/visibleinvisibly/4n7vsas7/
我知道将模板属性定义为可以注入 $element 和 $attrs 的函数(Angular 1.5 中的 template: function ($element, $attrs){ }),但我正在寻找其他方法。
提前致谢
【问题讨论】:
标签: javascript angularjs angularjs-scope