AngularJS empty fiddle
AngularJS empty fiddle
by michiganfootball20
HTML
<div ng-app="myApp" ng-controller="Ctrl">
<p>Missing Auth Orgs: {{missingAuthOrgs}}</p>
<p> </p>
<p>Missing Noc Orgs: {{missingNocOrgs}}</p>
</div>
JavaScript
var app = angular.module('myApp', []);
app.controller('Ctrl',['$scope',function($scope) {
$scope.missingAuthOrgs = [];
$scope.missingNocOrgs = [];
var initialize = function(authOrgs, nocOrgs) {
var authOrgMap = {};
var nocOrgMap = {};
authOrgs.forEach(function(org) {
authOrgMap[org.code] = org;
});
nocOrgs.forEach(function(org) {
nocOrgMap[org.dealerCode] = org;
});
for(var code in authOrgMap) {
if (!(code in nocOrgMap)) $scope.missingNocOrgs.push(authOrgMap[code]);
}
for(var code in nocOrgMap) {
if (!(code in authOrgMap)) $scope.missingAuthOrgs.push(nocOrgMap[code]);
}
};
var authOrgs = [
{
"id": "c4245a05-2965-457e-8958-59b4b6756899",
"tenantId": "cb497e36-ccb4-4337-aea6-ecf0a8921430",
"code": "B010",
"name": "ALBAN",
"description": "ALBAN TRACTOR COMPANY INC",
"createdAt": "2017-03-30T16:21:36.503458Z",
"updatedAt": "2017-03-30T16:21:36.503458Z",
"tenant": false
},
{
"id": "69865456-3f0a-4ace-8edd-5fab20ace889",
"tenantId": "cb497e36-ccb4-4337-aea6-ecf0a8921430",
"code": "B030",
"name": "ALTRF",
"description": "ALTORFER",
"createdAt": "2017-03-30T16:21:37.225788Z",
"updatedAt": "2017-03-30T16:21:37.225788Z",
"tenant": false
},
{
"id": "02849d43-2efc-40e0-89ce-117e08ab2d16",
"tenantId": "cb497e36-ccb4-4337-aea6-ecf0a8921430",
"code": "N140",
"name": "ATLTC",
"description": "ATLANTIC T & E",
"createdAt": "2017-03-30T16:21:37.918249Z",
"updatedAt": "2017-03-30T16:21:37.918249Z",
"tenant": false
},
{
"id": "c2d14961-d5c8-4554-bc2b-20e245e2da8d",
"tenantId": "cb497e36-ccb4-4337-aea6-ecf0a8921430",
"code": "D070",
"name": "BLNCH",
"description": "BLANCHARD MACHINERY CO",
"createdAt": "2017-03-30T16:21:38.729697Z",
"updatedAt": "2017-03-30T16:21:38.729697Z",
...