我是一个初学者到angular2 /打字稿我从两个文本框试图获取数和增加这两个数字中获得价值,并使用插值如何从文本框使用打字稿在角2
@Component({
selector: 'my-app',
template:
`<h1>Hello {{name}}</h1>
<h1>{{D}}</h1>
<form>
<p>first number:<input type="text" id="num1"></p>
<p>second number:<input type ="text1" id="num2"></p>
<h1> {{result}}</h1>
</form>
<test-app></test-app>`
})
export class AppComponent
{
name = 'Angular';
value : number;value1 : number;result:number;
constructor(value : number,value1 : number,result:number)
{
this.value = parseFloat
((document.getElementById("text") as HTMLInputElement).value);
this.value1 = parseFloat((document.getElementById("text1")
as HTMLInputElement).value);
this.result=this.value+this.value1;
}}
https://angular.io/docs/ts/latest/guide/user- input.html – echonax
绑定到表单元素是几乎所有角度教程的开始部分所涵盖的内容,包括主角2站点上的许多操作指南和教程。按照链接@echonax张贴,看看你是否可以弄明白。 – Igor
你有没有读过角度的东西? – Aravind