我练习角2,但得到" Bindings不能包含任务"这个错误

时间:2018-03-21 06:24:43

标签: angular typescript

<app-employeecount [all]= "gettotalemployeescount()"

&#13;
&#13;
<app-employeecount [all]= "gettotalemployeescount()"
                   [male]= "gettotalmaleemployeescount()"
                   [female]="gettotalfemaleemployeescount()"
                   (onEmployeeCountRadioButtonChange) = "onEmployeeCountRadioButtonChange($event)">
</app-employeecount>             
<br/>
<table>
  <thead>
    <tr>
      <th>id</th>
      <th>name</th>
      <th>Gender</th>
      <th>mobile</th>
      <th>Salary</th>
      <th>Date of joining</th>
    </tr>
  </thead>
  <tbody>
    <ng-container *ngFor = "let employ of employeelist;">
    <tr *ngIf = "selectedEmployeeCountRadioButton=='All' || selectedEmployeeCountRadioButton=employ.gender">
      <td>{{employ.id}}</td>
      <td>{{employ.name}}</td>
      <td>{{employ.gender}}</td>
      <td>{{employ.mobile}}</td>
      <td>{{employ.Salary | currency:'USD':'1.2-3'}}</td>
      <td>{{employ.Doa | date:'dd/MM/y' | uppercase}}</td>
    </tr>
  </ng-container>
    <tr *ngIf = "!employeelist || employeelist.length==0">
      <td colspan="6">No Students are available right now</td>
    </tr>
  </tbody>
</table>
&#13;
&#13;
&#13;

   [male]= "gettotalmaleemployeescount()"
               [female]="gettotalfemaleemployeescount()"
               (onEmployeeCountRadioButtonChange) = 
"onEmployeeCountRadioButtonChange($event)">
</app-employeecount>             
<br/>
<table>
<thead>
<tr>
  <th>id</th>
  <th>name</th>
  <th>Gender</th>
  <th>mobile</th>
  <th>Salary</th>
  <th>Date of joining</th>
</tr>
</thead>
<tbody>
<ng-container *ngFor = "let employ of employeelist;">
<tr *ngIf = "selectedEmployeeCountRadioButton=='All' || 
selectedEmployeeCountRadioButton=employ.gender">
  <td>{{employ.id}}</td>
  <td>{{employ.name}}</td>
  <td>{{employ.gender}}</td>
  <td>{{employ.mobile}}</td>
  <td>{{employ.Salary | currency:'USD':'1.2-3'}}</td>
  <td>{{employ.Doa | date:'dd/MM/y' | uppercase}}</td>
</tr>
</ng-container>
<tr *ngIf = "!employeelist || employeelist.length==0">
  <td colspan="6">No Students are available right now</td>
</tr>
</tbody>
</table>

1 个答案:

答案 0 :(得分:0)

您正在为* ngIf

中的selectedEmployeeCountRadioButton分配值

执行此操作<tr *ngIf = "selectedEmployeeCountRadioButton=='All' || selectedEmployeeCountRadioButton==employ.gender"></tr>

而不是<tr *ngIf = "selectedEmployeeCountRadioButton=='All' || selectedEmployeeCountRadioButton=employ.gender"></tr>