提供された JSON が有効なJSONであることを考慮して、必要なデータを取得する方法を示すフィドルを作成しました。JSON が無効です。
var myApp = angular.module('myApp',['ngTagsInput']);
myApp.factory('data', function() {
var data = [
{
"id": "74682309",
"labels": [
{
"text": "test1",
"probability": 0.069
},
{
"text": "test2",
"probability": 0.037
}
]
}];
return data;
});
myApp.controller('MyCtrl', ['$scope', 'data', function($scope, data) {
var values = [];
data.map(function(elem) {
return elem.labels.forEach(function(el) {
values.push({
"text" : el.text
});
});
});
$scope.tags = values;
}]);
そしてhtml部分:
<div ng-controller="MyCtrl">
<div class="elem">
<tags-input ng-model="tags"></tags-input>
</div>
</div>
ここにフィドルがあります:
http://jsfiddle.net/HB7LU/16554/
アップデート:
ng-tags-input
質問に角度拡張機能をタグとして含めていません。私の更新されたフィドルを見てください:
http://jsfiddle.net/HB7LU/16557/