AngularJS/bootstrap typeahead无法处理从$http.get调用返回的动态json
我有一个网页,其代码如下:AngularJS/bootstrap typeahead无法处理从$http.get调用返回的动态json,angularjs,typeahead,Angularjs,Typeahead,我有一个网页,其代码如下: <input type="text" class="form-control" ng-model="asynchSelected" typeahead="e as e.employee.fullName for e in searchEmployees($viewValue)"> [ { "employee": { "id": 0, "ful
<input type="text"
class="form-control"
ng-model="asynchSelected"
typeahead="e as e.employee.fullName for e in searchEmployees($viewValue)">
[
{
"employee": {
"id": 0,
"fullName": "Scott Nelson"
}
},
{
"employee": {
"id": 0,
"fullName": "Stacy Tester"
}
},
{
"employee": {
"id": 0, "fullName": "Suzy Schmoozy"
}
}
]
<input type="text"
class="form-control"
ng-model="selected"
typeahead="e as e.employee.fullName for e in employees | filter:$viewValue">
在文本框中键入时,我希望看到一个动态创建的员工姓名下拉列表,但我什么也没有得到…除了在浏览器调试器控制台上,我看到以下错误:
TypeError: Unable to get property 'length' of undefined or null reference
我认为我在typeahead中使用的表达式有问题,但我似乎找不到一个使用复杂json对象的好例子,该对象是通过typeahead控件从web服务中获取的
奇怪的是,如果我将json硬编码到一个名为“employees”的变量中,而不是尝试使用$http.get()返回它,则使用如下代码:
<input type="text"
class="form-control"
ng-model="asynchSelected"
typeahead="e as e.employee.fullName for e in searchEmployees($viewValue)">
[
{
"employee": {
"id": 0,
"fullName": "Scott Nelson"
}
},
{
"employee": {
"id": 0,
"fullName": "Stacy Tester"
}
},
{
"employee": {
"id": 0, "fullName": "Suzy Schmoozy"
}
}
]
<input type="text"
class="form-control"
ng-model="selected"
typeahead="e as e.employee.fullName for e in employees | filter:$viewValue">
它正确地显示了typeahead列表。。。??
任何帮助都将不胜感激。同样的问题……没有错误。试图下拉到简单的字符串,但仍然无法从http