有没有办法在我的组件中获取字符串“myModel”?
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `<input type="text" [(ngModel)]="myModel"/>`
})
export class AppComponent { // how can I access "myModel" here? }
答案 0 :(得分:0)
只需使用
访问它this.myModel
并在之前宣布。
myModel:string;
答案 1 :(得分:0)
最近的我可以来到NgModel通过injector.view进入ctor - 但需要根据http://blog.rangle.io/angular-2-ngmodel-and-custom-form-components/进行一些更改,看看我是否能够获得这些表达式。如果有人比我更早得到答案,请在这里发布。感谢名单。