【发布时间】:2019-02-28 03:12:26
【问题描述】:
当我使用$routeParams.id 获取 id 时,我正在尝试显示用户的信息,我已经仅使用文本显示了用户的信息,但是如何使用 img src 显示用户的图像?
在我的控制器中,我这样做是为了获取选定的用户。
.controller('editbloodrequestCtrl', function($scope,$routeParams, Bloodrequest) {
var app = this;
Bloodrequest.getBloodrequest($routeParams.id).then(function(data) {
if (data.data.success) {
$scope.newLastname = data.data.bloodrequest.lastname;
$scope.newFirstname = data.data.bloodrequest.firstname;
$scope.newImg = data.data.bloodrequest.img;
app.currentUser = data.data.bloodrequest._id;
} else {
app.errorMsg = data.data.message;
}
});
});
现在我得到了用户信息,我在前端显示了这个
<label>Lastname:</label>
<input class="form-control" type="text" name="lastname" ng-model="newLastname">
<label>Firstname:</label>
<input class="form-control" type="text" name="firstname" ng-model="newFirstname">
<label>Image:</label>
<img src ="" name="img" ng-model="newImg"> //how can I display the image here?
示例文档:
{firstname:"James",lastname:"Reid",img:"random.jpg"}
我的输出:
【问题讨论】:
标签: node.js angularjs mongodb mean-stack