在我的页面上,我正在基于api调用呈现表单。有了帮助几个过滤器,我隐藏了标题中有'id'且等于0的所有元素,但我需要显示初始元素Id。我会用'$ first'但第一个元素是复选框值,那怎么办呢?我感谢任何帮助。 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, '');
};
})
HTML
<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]}}" />
</div>
</div>
</div>
<button type="submit" class="btn btn-default" ng-if="rowData" ng-disabled="!rowValue">Submit</button>
</form>
答案 0 :(得分:1)
您可以使用ng-if
:
<div ng-repeat="thing in things">
<div ng-if="(thing === 'id' || thing.toLowerCase().endsWith('id') === false) ? true : false">
{{thing}}
</div>
</div>