我有一个这样的数据类型对象:
["Tag Name13", "Tag Name12"]
但是,如果我推动这个脚本:
var list_tag = [];
angular.forEach(retrive_data.tags, function(item){
list_tag.push(item.label);
});
$scope.tag = list_tag;
console.log中的输出是
[Object, Object, Object]
我打开这样的结构:
Array[3]
0
:
Object
1
:
Object
2
:
Object
是的,我的数据已推送但数据结构已更改,我无法在下一步中处理。我错了吗 ?请给我解决方案,谢谢
已更新
Array[2]
0 : "Tag Name13"
1 : "Tag Name12"
Array[2]
_id:"58a28112a6551f5b8a4fc0d3"
active:0
created_at:"2017-02-14 11:01:22"
description:"Lorem ipsum dolor sit amet, consectetur adipisci13"
image:"http://placehold.it/300x30013"
label:"Tag Name13"
meta_description:"Meta Description Tag Name13"
meta_keyword:"Meta Keywoprd Tag Name13"
meta_title:"Meta Title Tag Name13"
priority:100
related:"[]"
thread_count:0
thread_ids:Array[1]
updated_at:"2017-03-03 11:53:20"
url:"tag-name13"
答案 0 :(得分:0)
var list_tag = [];
angular.forEach(retrive_data.tags, function(item){
list_tag.push(item);
});
$scope.tag = list_tag;
我认为它应该像上面那样
答案 1 :(得分:0)
var testApp = angular.module('testApp', []);
testApp.controller('testController',['$scope', function testController($scope){
var retrive_data = [];
retrive_data.tags = [{'id':"58a28112a6551f5b8a4fc0d3",'active':0,'created_at':"2017-02-14 11:01:22",'description':"Lorem ipsum dolor sit amet, consectetur adipisci13",'image':"http://placehold.it/300x30013",'label':"Tag Name13",'meta_description':"Meta Description Tag Name13",'meta_keyword':"Meta Keywoprd Tag Name13",'meta_title':"Meta Title Tag Name13",'priority':100,'related':"[]",'thread_count':0,'updated_at':"2017-03-03 11:53:20",'url':"tag-name13"}, {'id':"58a28112a6551f5b8a4fc0d3",'active':0,'created_at':"2017-02-14 11:01:22",'description':"Lorem ipsum dolor sit amet, consectetur adipisci13",'image':"http://placehold.it/300x30013",'label':"Tag Name12",'meta_description':"Meta Description Tag Name13",'meta_keyword':"Meta Keywoprd Tag Name13",'meta_title':"Meta Title Tag Name13",'priority':100,'related':"[]",'thread_count':0,'updated_at':"2017-03-03 11:53:20",'url':"tag-name13"}];
var list_tag = [];
angular.forEach(retrive_data.tags, function(item){
list_tag.push(item.label);
});
$scope.tag = list_tag;
console.log($scope.tag);
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>
<div ng-app = "testApp" ng-controller="testController"></div>
答案 2 :(得分:0)
首先,您需要使用另一个变量,仅使用范围变量
检查我的代码
(X_train, Y_train), (X_test, Y_test) = mnist.load_data()