我无法在我的页面上访问其他用户个人资料页面

时间:2016-12-26 13:00:31

标签: angularjs node.js mongodb

我正在尝试通过单击用户名来重新定向用户在他的个人资料页面上获取数据。 我试图用ng-click这样做:

<p style="font-size:11px; color: grey; " ng-click="seeProfile(gterest);changelocation();"><b>{[{gterest.author}]}</b></p>

我的两个控制器功能:

$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>

这不会给我任何错误,但我的屏幕是空白的,我不知道该怎么办。 请帮忙!谢谢!

编辑: 我正在使用{{}}} {{}} {}},因为我使用了把手作为我的视图,所以在我的模块文件中我有

app.config(function ($interpolateProvider) {
    $interpolateProvider.startSymbol('{[{').endSymbol('}]}');
});

1 个答案:

答案 0 :(得分:0)

看起来您应该使用{{your_varibale}}而不是{[{your_varibale}]}。以下是更新后的代码。

<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>
相关问题