如何纠正范围的子元素在我的控制器
问题描述:
我在新的角度和现在我需要使用谷歌)如何纠正范围的子元素在我的控制器
据我控制器
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子元素?你们可以向我展示一些例子,或者只是告诉我我哪里有错误。我失去了更多的时间寻找解决方案。
答
在成功回调,
$scope.user= data.user;
在HTML
<img src="{{user.avatar_thumb}}">
<div class="activity-header">
<h2>{{user.username}}</h2>
+0
它不工作 –
'activities'没有这样的财产 –
检查答案 –