I am working with a JSON file that contains color information like this:
{
"colorsArray":[{
"colorName":"red",
"hexValue":"#f00"
},
{
"colorName":"green",
"hexValue":"#0f0"
},
{
"colorName":"blue",
"hexValue":"#00f"
},
{
"colorName":"cyan",
"hexValue":"#0ff"
},
{
"colorName":"magenta",
"hexValue":"#f0f"
},
{
"colorName":"yellow",
"hexValue":"#ff0"
},
{
"colorName":"black",
"hexValue":"#000"
}
]}
In my JavaScript file, I have the code snippet below where I use $http.get
to fetch the JSON data:
var app = angular.module('app', ['ngTagsInput']);
app.controller('MainCtrl', function($scope, $http) {
$scope.loadTags = function(query) {
return $http.get('tags.json');
};
});
I want to extract only the colorName
values from the JSON file when using AngularJS and making an external call with $http.get
. How can I achieve this?