javascript - Angular ng-repeat 变化值

标签 javascript angularjs

我正在使用 ng-repeat 制作一个带 Angular 表格。所有这一切都有效,但在某些情况下,json 会返回一些数据,如 PA-AC-DE,我想在待定、事件和停用的表中更改它。而且我不知道我该怎么做。 enter image description here

<table class="table table-bordered table-hover table-striped dataTable no-footer" data-sort-name="name" data-sort-order="desc">
    <tr role="row" class="info text-center">
        <th ng-click="order('msisdn')">Número Teléfono</th>
        <th ng-click="order('icc')">ICC</th>
        <!--th>IMEI</th-->
        <th ng-click="order('ActivationStatus')">Estado</th>
        <th ng-click="order('sitename')">Instalación</th>
        <th ng-click="order('siteaddress')">Dirección</th>
        <th ng-click="order('sitecity')">Ciudad</th>
        <th ng-click="order('sitezip')">Código Postal</th>
        <th ng-click="order('phonedesc')">Modelo Teléfono</th>
        <th ng-click="order('ContractingMode')">VBP</th>
    </tr>
    <tr class=" text-center" ng-repeat-start="object in filteredsites = (objects | filter:searchText) | filter:tableFilter| orderBy:predicate:reverse" ng-click="showDetails = ! showDetails">
        <td>{{object.msisdn}}</td>
        <td>{{object.icc}}</td>
        <td>{{object.ActivationStatus}}</td>
        <td>{{object.sitename}}</td>
        <td>{{object.siteaddress}}</td>
        <td>{{object.sitecity}}</td>
        <td>{{object.sitezip}}</td>
        <td>{{object.phonedesc}}</td>
        <td>{{ object.ContractingMode ? 'Yes': 'No'}}</td>
    </tr>
</table>

最佳答案

你可以使用过滤器

{{object.ActivationStatus | statusFilter}}

statusFilter 会是这样的:

angular.module('module', []).filter('statusFilter', function() {
    return function(input) {
        //switch-case
   };});

关于javascript - Angular ng-repeat 变化值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30910937/

相关文章:

angularjs - Angular 1.5 组件 + ng-model $formatters 和 $parsers

javascript - Sizzle.js(JQuery 选择器引擎)错误/bug

javascript - 关闭 Chromium 信息亭模式

javascript - Onsenui;[ng :areq] Argument 'AppController' is not a function, 在 angularjs 中未定义

javascript - 在 GET 响应中看不到 JSON 字段( Mongoose )

javascript - 构造动态变量 - AngularJS

javascript - 单元格模板中的 Angularjs 指令 ng-hide 不绑定(bind)网格数据的更改

php - 如何将php变量从链接传递到jquery ajax函数

javascript - 滚动链接

javascript - AngularJS 的 promise 是缓存