0
我是新來angularJS2.It可能是一個虛擬的問題你 我搜索了很多論壇,並沒有獲得輸入值在typeScript中的json值。你知道我應該如何編寫我的submit()函數來從屏幕獲取輸入值並在點擊提交按鈕時將其控制到屏幕?你可以找到下面的代碼。如果您有任何疑問,請讓我知道。如何解析HTML輸入值json數據在angular2使用typeScript
問候
<!DOCTYPE html>
<html>
<form name="myForm" ng-submit="submit()">
<head>
<link rel="stylesheet" href="guiTransformatorStyles.css">
</head>
<body>
<table>
<br>
<ul class="nav nav-pills nav-stacked">
<tr><td> <input type="text" value=" " ng-model="myForm.productName"> </td></tr>
</ul>
</table>
</body>
</form>
</html>
這是我的打字稿文件:
import { Component, OnInit} from '@angular/core';
import { Router } from '@angular/router';
import { FormGroup, FormBuilder } from '@angular/forms';
import { Http } from '@angular/http';
@Component({
moduleId: module.id,
templateUrl: 'navigation.component.html',
host: {'(window:keydown)' : 'hotkeys($event)'},
})
export class NavigationComponent implements OnInit {
form: FormGroup;
ngOnInit(): void { }
constructor(private router: Router) {
}
submit() {
alert('submit');
}
}
...'NG-model'和'NG-submit'是AngularJS語法。 ... – Alex
[plnkr](https://embed.plnkr.co/QllfZvOlQ8hNhhrU1KMY/)像這樣? –