Reputation:
I am using typeahead
, I like it to fetch dynamic data it's more useful
<input required type="text" ng-model="student"
placeholder="{{'STUDENT_ID_FIRST_NAME_LAST_NAME' | translate}}"
typeahead="student as student.lastName for student in getStudents($viewValue)"
typeahead-loading="loading" class="form-control">
My javascript code to fetch students is
$scope.getStudents = function(val) {
var queryCriteria = {
q: JSON.stringify([{
field: 'lastName',
op: APP_CONSTANTS.SEARCH_OPERATORS.CONTAINS,
value: val
}, {
field: 'firstName',
op: APP_CONSTANTS.SEARCH_OPERATORS.CONTAINS,
value: val
}, {
field: 'userId',
op: APP_CONSTANTS.SEARCH_OPERATORS.CONTAINS,
value: val
}]),
joinCondition: APP_CONSTANTS.JOIN_CONDITIONS.OR,
order: APP_CONSTANTS.SORTING_ORDER.DESCENDING,
limit: 10,
orderBy: 'createdAt',
page: 1
}
return Students.query(queryCriteria).then(function(response) {
return response.data;
});
};
I want to show concatenation of student.lastName
and student.firstName
. Please suggest how to do
Upvotes: 3
Views: 51
Reputation: 136144
You could simply do use string concatenation student.lastName + ' ' + student.firstName
<input required type="text" ng-model="student"
placeholder="{{'STUDENT_ID_FIRST_NAME_LAST_NAME' | translate}}"
typeahead="student as student.lastName+' '+student.firstName for student in getStudents($viewValue)"
typeahead-loading="loading" class="form-control">
Upvotes: 2