2017-04-06 92 views
0

这里进出口新的angularTypescript请帮助我如何绑定TextBoxData.Like 在这里,我有两个textBoxt和一个按钮如何文本框的值打至梅索德使用AngularTypescript

<div> 
    <input type="text" class="form-control" id="txtx1" /> 
    <br /> 
    <input type="text" class="form-control" id="txtx" /> 
    <input type="button" class="btn btn-success" value="Submit" ng-click="GetData()" /> 
</div> 

这里我怎样才能绑定这两个打字稿中的文本框值Like

public class Employeee(Employee ee) 
{ 
} 
+2

什么是你想要的实际问题解决?为什么你想在TypeScript中做到这一点?通常视图绑定是最好的方法。见https://angular.io/docs/ts/latest/guide/template-syntax.html –

+1

和ng-click是AngularJS ... – Alex

+0

请建议我如何绑定这两个值像这里我的目标是插入数据 –

回答

0

Angular不像Angular 1那样工作。您需要更改很多以获得此工作。我会建议你通过这个link。你可以试试下面的代码

<div> 
     <input type="text" class="form-control" id="txtx1" [(ngModel)]="fname" /> 
     <br /> 
<input type="text" class="form-control" id="txtx" [(ngModel)]="lname" /> 
     <input type="button" class="btn btn-success" value="Submit" (click)="GetData()" /> 
    </div> 

public class Employeee(Employee ee) 
{ 
    GetData() { console.log(this.fname +','+ thislname); } 
    //you can assign this.fname = 'hello'; 
} 
+0

可能会提请代码或任何网址 –

+0

我给你上面的链接。点击它的更多细节如何使用表格 –

+0

你检查上面的代码? –

0

您可以创建一个角度分量这样创建双向绑定,使用打字稿

import { Component } from '@angular/core'; 

@Component({ 
    selector: 'a-selector', 
    template: `<div> 
        <input type="text" class="form-control" id="txtx1" [(ngModel)]="text1"/> 
         <br /> 
        <input type="text" class="form-control" id="txtx" [(ngModel)]="text2"/> 
        <input type="button" class="btn btn-success" (click)="GetData()" /> 
       </div>` 
}) 
export class EmployeeComponent { 
    text1: string; 
    text2: string; 

    GetData(): void{ 

    } 
} 

问候

相关问题