JSFiddle - React, Tailwind, and code Playground

by Alaksandar Jesus Gene

HTML

<div ng-controller="testCtrl">
  {{sortData}}
</div>

JavaScript

var app = angular.module('testApp',[]);
app.controller('testCtrl', function($scope){

  var  sortData =  {
    "accountStatus": "Account status",
    "lineStatus": "Line/mobile status",
    "accountType": "Account type",
    "accountSubType": "Account subtype",
    "accountId": "Account #",
    "msisdn": "Line/mobile #",
    "sim": "SIM/ICCID/CSNID",
    "name": "Name"
  }
  var   results =  [
    {
      "msisdn": "7788778606",
      "sim": "0",
      "firstName": "Tray",
      "lastName": "Richardson",
      "lineStatus": "Active",
       "accountId": "234234328",
      "accountStatus": "",
      "accountType": "Individual",
      "accountSubType": "Postpaid",
      "customerId": "1234567890",
      "segmentationId": "",
      "sourceSystem":""
    },
    {
      "msisdn": "7788778606",
      "sim": "1",
      "firstName": "David",
      "lastName": "Martin",
      "lineStatus": "Cancelled",
      "accountId": "234234200",
      "accountStatus": "",
      "accountType": "Business",
      "accountSubType": "Prepaid",
      "customerId": "0123456789",
      "segmentationId": "",
      "sourceSystem":""
    }
  ]
  
  
  
  <!-- Coding Starts Here -->
  sortDataKeys = Object.keys(sortData); // take keys out of the sort object

  angular.forEach(results,function(result){ // create a new value in result by concatenating firstname and lastname
  	result.name = result.firstName+" "+result.lastName;
  })
  
  
  var removeSortDataKeys = []; // Assign a empty array that will get keys to be removed from the sort object
  angular.forEach(sortDataKeys, function(key){ // for each sortDataKeys
  hasValidValue = false;           							// Assume it does not have a valid value. so false.
  	angular.forEach(results, function(result){  	// check the result whether it has a valid value
      if(result[key]!=""){											// if true, i.e.not equal to empty string
      	hasValidValue = true;										// change the assumption false to true
      }
    })
   if(!hasValidValue)...