【发布时间】:2016-05-11 13:55:25
【问题描述】:
为什么我不能从类中的函数更改视图中的数据?
wrap.component.ts
@Component({
selector: 'wrap',
templateUrl: './templates/wrap.html'
})
export class WrapComponent {
public test: string;
constructor () {
this.test = 'Hello world';
}
fun () {
this.test = 'SPAM';
}
}
express.component.ts
import {WrapComponent} from './wrap.component';
export class Express {
constructor () {
new WrapComponent().fun();
}
}
wrap.html
<h2>{{test}}</h2>
为什么在视图中测试变量是“Hello world”?
【问题讨论】:
标签: javascript angularjs data-binding typescript angular