我正在使用typeahead
,我喜欢它来获取更有用的动态数据
<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">
我提取学生的javascript代码是
$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;
});
};
我希望显示student.lastName
和student.firstName
的串联。请建议怎么做
答案 0 :(得分:2)
您可以使用字符串连接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">