【发布时间】:2015-07-11 12:48:26
【问题描述】:
我想引用 A 中组件的属性。该组件的构造函数 B.该组件的模板。这方面的 api 似乎有点变化,但我希望以下工作:
<my-component [greeting]="hello"></my-component>
// my component.es6.js
@Component({
selector: 'my-component',
properties: {
'greeting': 'greeting'
}
})
@View({
template: '{{greeting}} world!'
})
class App {
constructor() {
console.log(this.properties) // just a guess
}
}
我做错了什么?
【问题讨论】:
-
我不确定当前版本的 Angular 是否可行。我四处看看
angular2_material是如何处理它的,但是当我尝试这些技术时,它要么什么也没做,要么它们使用了我的 angular2 中没有的功能(刚才从 npm 中提取)。 (1)[md-button][href]是我发现的一个简单示例,它只期望tabIndex(使用hostProperties,而不是properties)将绑定到对象,但在我的代码中,它永远不会。 (2)md-radio-button使用@Attribute,TypeScript 不会为我编译(angular2/angular2 没有导出的memember 'Attribute')。 -
@Langdon 很有趣,感谢您的调查!现在情况似乎有些不稳定,这是意料之中的。
标签: javascript ecmascript-6 angular