user7052596
user7052596

Reputation:

angularjs ng-if not working in Form

I am trying using ng-if in my HTML

HTML

<td width=15% ng-if="value == I">Decision</td>  
<td width=10% ng-if="value != I">Status</td> 

JS

    $scope.value = "I";

I am getting $scope.value value in my HTML. But ng-if not working.

More infomation please lookout http://jsfiddle.net/n3xWB/1493/

Thanks.

Upvotes: 1

Views: 1471

Answers (2)

Anand Siddharth
Anand Siddharth

Reputation: 977

Try ng-hide instead of ng-if and also you missed the quotes " 'I' "

<td width=15% ng-hide="value == 'I'">Decision</td>  
<td width=10% ng-hide="value != 'I'">Status</td>

Upvotes: 3

Sachila Ranawaka
Sachila Ranawaka

Reputation: 41437

missed the quote around the ng-if values

<td width=15% ng-if="value == 'I'">Decision</td>  
<td width=10% ng-if="value != 'I'">Status</td> 

 
angular.module("app",[])
.controller("TodoCtrl",TodoCtrl )

 function TodoCtrl($scope) {

    $scope.value = "I";
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app">
  <div ng-controller="TodoCtrl">
       <table>
        <tr>
           value =================== {{value}}
            <td width=15% ng-if="value == 'I'">Decision</td>  
           <td width=10% ng-if="value != 'I'">Status</td> 
        </tr>

    </table>
  </div>
</div>

Upvotes: 1

Related Questions