"use strict";
appCore.controller("ContactViewCtrl", ["$state", "$scope", "$http", "$timeout", "vServices", function ($state, $scope, $http, $timeout, vServices) {
  $scope.param = $state.params;
  $scope.$root.page.title = "Contact View";
  $scope.contacts = [];
  const init = function () {
    if ($scope.param && typeof $scope.param.contactid !== "undefined") {
      vServices.callApi("contact/" + $scope.param.contactid, "GET", {}).then((obj) => {
        if (obj) {
          let localContactsObj = [];
          for (let key in obj)
            if (obj.hasOwnProperty(key))
              if ("contactid acc_id".indexOf(key) === -1)
                localContactsObj.push({key: key.replace(/_/, " "), value: obj[key]});
          $scope.contacts = localContactsObj;
        }
      });
    }
  };
  init();
}]);
