JSON結構我使用laravel並在數據庫中存儲一個JSON字符串:存儲和獲取數據庫
[{label: 'Introduction',id: 'ABC'},{label: 'Chapter one',id: 'DEF'}]
我想使用的角度來得到這個字符串,並以一個jQuery插件樹用它。我似乎無法正確檢索字符串。它總是在控制檯中出現undefined
。我錯過了什麼?
DB查詢:
DB::table('documents')->where('id',Input::json('id'))->get(array('structure'));
角控制器:
TopicService.load($scope.publication).success(function(data) {
$('#topics').tree({
data: data.structure
});
});
什麼是數據內容。 console.log(data) – ArtisticPhoenix 2014-11-09 01:58:05
@ArtisiticPhoenix一個像這樣的對象'structure:「[{label:'Introduction',id:'ABC']},{label:'Chapter one',id:'DEF']}]」 ' – greener 2014-11-09 02:01:54
- 那是.tree()期望的?顯然它不是未定義的,你的問題有點含糊 – ArtisticPhoenix 2014-11-09 02:04:34