根据条件在ng-grid中显示数据

时间:2015-09-22 10:33:47

标签: javascript html angularjs ng-grid

只有在满足某些条件时才显示ng-grid中的数据。我想过使用filteroptions。我是angularjs.的新手。所以我不知道该怎么做。

我的jsfile:

var app = angular.module('myApp', ['ngGrid']);
app.controller('MyCtrl', function($scope) {
$scope.myData = [{name: "Moroni", age: 50},
                {name: "Tiancum", age: 43},
                {name: "Jacob", age: 27},
                {name: "Nephi", age: 29},
                {name: "Enos", age: 34}];
$scope.gridOptions = { 
    data: 'myData',
    columnDefs: [{field: 'name', displayName: 'Name'},
                 {field:'age', displayName:'Age'}]
    };

});

我的htmlfile:

<html ng-app="myApp">  
<head lang="en">
    <meta charset="utf-8">
    <title>Getting Started With ngGrid Example</title>  
    <link rel="stylesheet" type="text/css" href="ng-grid.css" />
    <link rel="stylesheet" type="text/css" href="style.css" />
    <script type="text/javascript" src="jquery-1.8.2.js"></script>
    <script type="text/javascript" src="angular.js"></script>
    <script type="text/javascript" src="ng-grid-1.3.2.js"></script>
    <script type="text/javascript" src="main.js"></script>
</head>
<body ng-controller="MyCtrl">
    <div class="gridStyle" ng-grid="gridOptions"></div>
</body>

我的要求是只在年龄大于30时才显示html中的记录。

0 个答案:

没有答案