有没有办法在我的组件中获取字符串“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? }
有没有办法在我的组件中获取字符串“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? }
只需访问它
this.myModel
并在之前声明。
myModel:string;
最接近 NgModel 的我是通过 injector.view 在 ctor 中 - 但需要根据http://blog.rangle.io/angular-2-ngmodel-and-custom-form-components/进行一些更改才能看到如果我能得到这些表达。如果有人比我早得到答案,请在此处发布。谢谢。