I have a list which sometimes has true
or false
value. When I'm using ng-repeat
to show the list with the value inside an <input type="text">
, I'd like to have <input type="checkbox">
if the value matches a boolean.
<table class="table table-hover table-striped table-bordered">
<tbody>
<tr ng-repeat="parameter in parameter_list">
<th class="text-left">
{{parameter.title | uppercase}}
</th>
<td class="text-left">
<div class="form-group">
<input type="text" ng-model="parameter_list[$index].value" class="form-control">
</div>
</td>
</tr>
</tbody>
</table>
Any ideas, how can I achieve this ?
Fiddle
Edit : It's not a duplicate since I don't have the input
type
in a $scope
variable.
Just keep it simple:
<input type="{{typeInput}}" />
And in your controller:
$scope.typeInput = 'number';
Works like a charm, without all that extra code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With