Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AngularJS/bootstrap typeahead无法处理从$http.get调用返回的动态json_Angularjs_Typeahead - Fatal编程技术网

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