我如何獲得一個HTML input元素在我的組件類的價值?如何獲取Angular 2中的HTML元素的值?
例如,我想從這個輸入元素的用戶名在我的組件類。
<div class="row">
<div class="input-field col s12">
<input id="username" type="text" class="validate" name="username">
<label for="username">Username</label>
</div>
</div>
那麼我需要的價值在我的組件類:
export class HomepageComponent {
username = username;
}
https://angular.io/docs/ts/latest/guide/template-syntax.html如何使用ngModel? :) – Alex
是的,我一直在研究有關ngModel,但我不能換我周圍的適當頭結合使用。 @ ajt-82 – proton
我建議你看看教程。你有一個答案,是的,但如果你看看這個教程,你會得到一些基礎知識。從這裏開始:https://angular.io/docs/ts/latest/tutorial/toh-pt1.html :) – Alex