【发布时间】:2016-02-15 12:47:13
【问题描述】:
我正在使用 GET 加载一些用户配置文件数据,就像这样 -
MainController.js
$http({
method: 'GET',
url: config.serverUrl + '/profile'
}).then(function successCallback(response) {
$scope.userdata = response.data.message.user;
}, function errorCallback(response) {
toastr.error('Something is wrong.');
});
服务器响应
{
"success": true,
"message": {
"user": {
"id": 36,
"email": "user@gmail.com",
"name": "Rusty Rittenhouse"
}
}
}
现在,我使用以下表达式来显示用户名:
{{ userdata.name }} -> inputs "Rusty Rittenhouse"
我怎样才能只显示“Rusty”? 通常我会使用拆分,但由于我是 Angular 新手,我不知道什么是最好和最简洁的解决方案。
【问题讨论】:
标签: angularjs expression