Search code examples
angularjsshow-hideangular-ng-if

Show Empty textbox if model has zero value AngularJs


I have textbox in my view as following :

<input id="line1 " name="line1" ng-readonly="locked == true" ng-show="lineData[0].line != 0" ng-model="lineData[0].line" class="form-control" type="text" required />

I just want to show an empty textbox if lineData[0].line = 0 else it shows the actual value. How can acheive this? Can anyone help me to do this?

Thanks in advance


Solution

  • why you are using ng-show="lineData[0].line != 0".. you need clear textbox or hide textbox.. clear code.

     $scope.lineData[0].line = $scope.lineData[0].line != 0 ? $scope.lineData[0].line : null;