0
我在新的角度和現在我需要使用谷歌)如何糾正範圍的子元素在我的控制器
據我控制器
var user = AuthService.getUser();
$http.get("http://hannation.me/api/userplus/activities/", {
params: {
key: '57f211a0354d7',
comment: true,
cookie: user.cookie,
user_id: user.data.id
}
}).success(function(data) {
$scope.activities = data.activities;
$scope.activities.comments = [];
$scope.activities.comments = data.activities.comments;
$ionicLoading.hide();
$scope.$broadcast('scroll.refreshComplete');
});
這家4小時後找到我的問題答案是我的HTML
<div class="list card activity-card" ng-repeat="activity in activities">
<div class="item item-avatar">
<img src="{{activity.user.avatar_thumb}}">
<div class="activity-header">
<h2>{{activity.user.username}}</h2>
<p>{{activity.time}}</p>
</div>
</div>
<div class="item item-body">
<div ng-bind-html='activity.content | limitHtml2 | limitHtml3' class="activity-content"> </div>
</div>
<div class="list card" ng-repeat="comment in activities.comments">
<div class="item item-avatar">
<img src="{{comment.avatar}}">
<div class="activity-header">
<p>{{comment.content}}</p>
</div>
</div>
</div>
<div class="item item-body activity-footer">
<a ui-sref="app.tabs.activity-single({id :activity.activity_id})" class="button button-full button-assertive">
<i>More</i>
</a>
</div>
</div>
這是我的JSON文件
{
"activity_id": "914",
"component": "blogs",
"action": "mr. Whale wrote a new post, Mountain",
"content": "Let the seasons guide your way to an unforgettable vacation in the North Carolina mountains. Spring brings crisp, fresh air perfect for hiking the Appalachian Trail or biking the trails at Rocky Knob Mountain Bike […] <img src=\"http://hannation.me/wp-content/uploads/2016/10/winter_snow_nature_landscape_1900x1200-792x500.jpg\"/>",
"user": [
{
"user_id": 1,
"username": "adminara",
"avatar": "http://hannation.me/wp-content/uploads/avatars/1/57f4791724d01-bpthumb.jpg",
"display_name": "mr. Whale"
}
],
"type": "new_blog_post",
"time": "2016-10-06 05:30:43",
"time_since": "5 days, 3 hours ago",
"is_hidden": false,
"is_spam": false,
"is_fav": false,
"can_delete": true,
"comments": [
{
"id": 916,
"component": "activity",
"user_id": 5,
"avatar": "http://hannation.me/wp-content/uploads/avatars/5/57777a4e865b4-bpthumb.jpg",
"content": "И @adminara, ты специально выбрал описание про северную Каролину? Я же там год жил!",
"action": "RT posted a new activity comment",
"item_id": 914,
"secondary_item_id": 914,
"is_fav": false,
"can_delete": true,
"date_recorded": "2016-10-10 23:55:21",
"time_since": "8 hours, 48 minutes ago",
"hide_sitewide": "0",
"display_name": "RT",
"depth": 1,
"is_spam": "0",
"children": [],
"mptt_left": "4",
"mptt_right": "5"
},
{
"id": 917,
"component": "activity",
"user_id": 1,
"avatar": "http://hannation.me/wp-content/uploads/avatars/1/57f4791724d01-bpthumb.jpg",
"content": "жосмлдомсочмочясмдосмдлоячсдлмодлывфывыф",
"action": "mr. Whale posted a new activity comment",
"item_id": 914,
"secondary_item_id": 914,
"is_fav": false,
"can_delete": true,
"date_recorded": "2016-10-11 01:49:19",
"time_since": "6 hours, 54 minutes ago",
"hide_sitewide": "0",
"display_name": "mr. Whale",
"depth": 1,
"is_spam": "0",
"children": [],
"mptt_left": "6",
"mptt_right": "7"
},
{
"id": 918,
"component": "activity",
"user_id": 1,
"avatar": "http://hannation.me/wp-content/uploads/avatars/1/57f4791724d01-bpthumb.jpg",
"content": "@rtwest Да вообще не видно не фига! До этого все было видно)",
"action": "mr. Whale posted a new activity comment",
"item_id": 914,
"secondary_item_id": 914,
"is_fav": false,
"can_delete": true,
"date_recorded": "2016-10-11 01:49:51",
"time_since": "6 hours, 54 minutes ago",
"hide_sitewide": "0",
"display_name": "mr. Whale",
"depth": 1,
"is_spam": "0",
"children": [],
"mptt_left": "8",
"mptt_right": "9"
}
]
},
如何我可以更正$範圍到我的頁面子元素評論與ng和用戶喜歡單個?我正在嘗試更多不同的方式,它不起作用。如何工作$ scope子元素?你們可以向我展示一些例子,或者只是告訴我我哪裏有錯誤。我失去了更多的時間尋找解決方案。
'activities'沒有這樣的財產 –
檢查答案 –