我正在尝试构建一个简单的组件,只是一个输出参数但没有显示参数的div:
test.html
<ion-content padding class="getting-started">
<my-component [test]="Something"></my-component>
</ion-content>test.ts
import {Page} from 'ionic-framework/ionic';
import {MyComponent} from './myComponent';
@Page({
templateUrl: 'build/pages/test/test.html',
directives: [MyComponent]
})
export class TestPage {
constructor() {
}
}myComponent.ts
import {Component,Input} from 'angular2/core';
@Component({
selector: 'my-component',
template: `
<div>Param: {{test}}</div>
`,
})
export class MyComponent {
@Input() test;
constructor() {
}
}结果:

我想不出我错过了什么。
发布于 2016-02-11 17:40:20
您的代码与文档(https://angular.io/docs/ts/latest/api/core/Input-var.html)相同,除了[test]="Something"之外,您是否尝试过编写test="Something"?
我认为[]语法只能使用组件的变量。
发布于 2016-02-17 17:56:43
我不确定,但试试test=“某样东西”
https://stackoverflow.com/questions/35345822
复制相似问题