功能图从何而来?

Where does the function map come from?

所有。原谅我在AngularJS和AugularJS-UI.

中表现不佳

目前,我正在尝试让 typeahead 指令在我的页面中工作。

这是代码。请审核。

Html

<tr ng-repeat="item in DetailsOfCurRecipe">
                <td><div id="scrollable-dropdown-menu"><input name="DrugDetailName" ng-model="item.ProductName" typeahead="address for address in getDrugDetails($viewValue)" /></div><input type="hidden" name="DrugDetailID" value="{{item.ID}}" /><input type="hidden" name="DrugFileID" value="{{item.DrugFileID}}" /></td>
</tr>

JS

$scope.getDrugDetails = function (val) {
        return $http.get('http://localhost:6249/api/DrugDetails/all', {}).then(function (response) {
            return response.data.map(function (item) {
                return item.ProductName;
            });
        });
    };

我只想知道response.data.map函数是从哪里来的?谢谢

来自the Array prototype. It is part of standard core JavaScript.

response.data 是来自 angular http 服务的对象,map 是本机 Javascript 函数。下面是 map 函数的定义:

The map() method creates a new array with the results of calling a provided function on every element in this array.