0
我有我的JSON文件如下
{
"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"
}
]}
以及特定我的js文件如下.....我用$http.get
功能
var app = angular.module('app', ['ngTagsInput']);
app.controller('MainCtrl', function($scope, $http) {
$scope.loadTags = function(query) {
return $http.get('tags.json');
};
});
這裏如何讀取JSON文件當使用AngularJS在$http.get
中外部引用JSON文件時,我能否僅將colorName
解析爲元素?