Go back to the main page

Properly constructing a Coffeescript Array of Objects

This article is over 2 years old. Proceed with caution.

Regards ♨ – Minimul

 

  data: ->
    categories:[
      label: "annhhx10"
      category: "Products"
    ,
      label: "zippers"
      category: "Products"
    ,
      label: "bizdev"
      category: "Charts"
    ,
      label: "loadables"
      category: "Charts"
    ]

  // Outputs

  SelectableDropdown.prototype.data = function() {
    return {
      categories: [
        {
          label: "annhhx10",
          category: "Products"
        }, {
          label: "zippers",
          category: "Products"
        }, {
          label: "bizdev",
          category: "Charts"
        }, {
          label: "loadables",
          category: "Charts"
        }
      ]
    };
  };

Comment on this article?