函数图从哪里来

Where does the function map come from?

本文关键字:函数      更新时间:2023-09-26

全部。请原谅我在AngularJS和AugularJS UI方面做得不好。

目前,我正在尝试在我的页面中执行打字指令。

这是代码。请查看。

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函数是从哪里来的?谢谢

它来自Array原型。它是标准核心JavaScript的一部分。

response.data是来自angular http服务的对象,映射是一个本地Javascript函数。以下是map函数的定义:

map((方法使用调用为此数组中的每个元素提供了函数。