Angularjs 我能';在访问另一个用户配置文件页面时,无法在我的页面上获取ng重复数据
我正试图通过点击一个用户名来获取数据,从而在他的个人资料页面上重定向该用户。 我正在尝试使用ng单击来执行此操作,如下所示:Angularjs 我能';在访问另一个用户配置文件页面时,无法在我的页面上获取ng重复数据,angularjs,node.js,mongodb,Angularjs,Node.js,Mongodb,我正试图通过点击一个用户名来获取数据,从而在他的个人资料页面上重定向该用户。 我正在尝试使用ng单击来执行此操作,如下所示: {[{gterest.author}]} 我的两个控制器功能: $scope.seeProfile = function (gterest) { console.log(gterest); var user = gterest.author; $http.post('/userProfile/', {user: user})
{[{gterest.author}]}
我的两个控制器功能:
$scope.seeProfile = function (gterest) {
console.log(gterest);
var user = gterest.author;
$http.post('/userProfile/', {user: user}).then(function (results) {
console.log(results);
$scope.userProfileList = results.data;
})
};
$scope.changelocation = function () {
$window.location.href = '/userProfile/';
}
我的服务器功能:
router.post('/', function (req, res) {
var user = req.body.user;
console.log(user);
mongoose.model('Gterest').find({"author": user},function(err, gterests){
if(err) console.log(err);
console.log(gterests)
res.json(gterests);
});
})
在这里,我试图显示数据:
<div ng-controller="allGterest">
<div masonry>
<div class="masonry-brick pinterest" ng-repeat="user in userProfileList">
<img ng-src="{[{user.image}]}" alt="aaa" style="width: 238px;">
<p style="font-size:11px; color: grey; "><b>{[{user.author}]}</b></p>
<p style="margin-top: 5px;" ><b>{[{gterest.title}]}</b></p>
<button class="btn btn-danger btn-xs" style="margin-bottom: 2px;"><span class="glyphicon glyphicon-heart"></span></button>
</div>
</div>
</div>
看起来您应该使用
{{your_varible}}
而不是{[{your_varible}]}
。下面是更新的代码
<div ng-controller="allGterest">
<div masonry>
<div class="masonry-brick pinterest" ng-repeat="user in userProfileList">
<img ng-src="{{user.image}}" alt="aaa" style="width: 238px;">
<p style="font-size:11px; color: grey; "><b>{{user.author}}</b></p>
<p style="margin-top: 5px;" ><b>{{gterest.title}}</b></p>
<button class="btn btn-danger btn-xs" style="margin-bottom: 2px;"><span class="glyphicon glyphicon-heart"></span></button>
</div>
</div>
</div>
{{user.author}
{{gterest.title}
对不起,我忘了提到我的坏消息,我使用了{[{my_variable}},因为我使用了手柄,在我的模块文件中我使用了app.config(function($interpolateProvider){$interpolateProvider.startSymbol('{[{').endSymbol('}]});
所以在我的例子中{{{}}={{{}}}}}}}为什么要同时使用Angular Js和把手?把手的整个属性都由Angular Js顺利处理。
<div ng-controller="allGterest">
<div masonry>
<div class="masonry-brick pinterest" ng-repeat="user in userProfileList">
<img ng-src="{{user.image}}" alt="aaa" style="width: 238px;">
<p style="font-size:11px; color: grey; "><b>{{user.author}}</b></p>
<p style="margin-top: 5px;" ><b>{{gterest.title}}</b></p>
<button class="btn btn-danger btn-xs" style="margin-bottom: 2px;"><span class="glyphicon glyphicon-heart"></span></button>
</div>
</div>
</div>