title: How To Declare Array Of Objects Globally In Angular
body: <p>I have an object that I'm using in multiple places in my component.ts file and I want to know how I can declare it globally or somehow turn it into it's own static class.</p>
  
  <pre><code>  calculateStandard(change) {
  /* this function calculates the standard change for a transaction (most efficent denominations) */
  // TODO make the denominations object a global variable or model
  var denominations = [
    {name: "twenty", plural: "twenties", value: 20.00},
    {name: "ten", plural: "tens", value: 10.00},
    {name: "five", plural: "fives", value: 5.00},
    {name: "one", plural: "ones", value: 1.00},
    {name: "quarter", plural: "quarters", value: 0.25},
    {name: "dime", plural: "dimes", value: 0.10},
    {name: "nickle", plural: "nickles", value: 0.05},
    {name: "penny", plural: "pennies", value: 0.01}
  ];
  var result = denominations.reduce(function(accumulator, currentDenomination) {   // iterates through the denomination object from top to bottom
    if (change &gt;= currentDenomination.value) {
      var currentValue = 0.00;    // the amount of coins/bills for each denomination
      while (change &gt;= currentDenomination.value) {
        currentValue ++;
        change -= currentDenomination.value;
        change = Math.round(change * 100) / 100   // prevents nasty decimal issues in TypeScript
      }
      if (currentValue &gt; 1) {   // checks to see if the plural denomination name should be used or not
        accumulator.push({name: currentDenomination.plural, amount: currentValue});
      } else {
        accumulator.push({name: currentDenomination.name, amount: currentValue});
      }
      return accumulator;
    } else {
      return accumulator;
    }
  }, []);   // the empty array is the initial accumulator
  return result
  }
  </code></pre>
  
  <p>the <code>denominations</code> object is the object I'm trying to declare globally.</p>