Anton Anton - 4 months ago 17
AngularJS Question

ng-repeat hide all elements except initial

On my page I'm rendering the form based on api call. With help couple filters I'm hiding all elements which have 'id' in title and which equal 0, but I need to display initial element Id. I would used '$first' but the first element is checkbox value, so how can it be done? I appreciate for any help. applied plunk

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope, $http) {

$scope.upload = function (){

$scope.rowKeys = Object.keys($scope.rowData);


app.filter('hide', function () {
return function(input, arg) {
return input.replace(arg, '');


<form style="padding: 15px">
<button class="btn btn-default" ng-click="upload()">Upload</button>
<div class="form-group row">
<div ng-repeat="k in rowKeys | filter: '!id' | filter: '!0'" ng-model="rowValue">
<label for="rowValue" class="col-sm-2">{{k | hide:'.name'}}:</label>
<div class=" col-sm-2">
<input class="form-control rowValue" id="rowValue" value="{{rowData[k]}}" />
<button type="submit" class="btn btn-default" ng-if="rowData" ng-disabled="!rowValue">Submit</button>


You can make use of ng-if for this:

<div ng-repeat="thing in things">
    <div ng-if="(thing === 'id' || thing.toLowerCase().endsWith('id') === false) ? true : false">