I'm using GET to load some user profile data, like so -
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.');
});
Server response
{
"success": true,
"message": {
"user": {
"id": 36,
"email": "[email protected]",
"name": "Rusty Rittenhouse"
}
}
}
Now, I'm using the following expression to show the user's name:
{{ userdata.name }} -> inputs "Rusty Rittenhouse"
How can I display only "Rusty"? Usually I would use split, but since I'm new to angular I don't know what's the best and most neat solution for this.