简体   繁体   English

ajax请求的angular成功方法编译出错

[英]Compilation error in angular success method for ajax request

This is an angular app and I am trying to call a function on success of an ajax call.这是一个有角度的应用程序,我试图在 ajax 调用成功时调用一个函数。

Compiler error on lines 3-6 in the following code and I have no idea why, please explain where I have gone wrong.以下代码第 3-6 行的编译器错误,我不知道为什么,请解释我哪里出错了。

   $http.get(ROOT_API+"webapi/public/events/" + $scope.appId + "/eventTypes").success(
     function(data){
         var sports = [];
         data.forEach(sport -> {
           sports.push({"name":sport})
         });
         $scope.sports = sports;
     }
   );
 }

我一直在使用很多 Java,所以我没有使用我使用的胖箭头函数 -> 而是导致奇怪的编译错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在请求期间修改jQuery $ .ajax()成功方法 - Modifying jQuery $.ajax() success method during request Ajax请求成功处理程序 - Ajax request success handler 成功完成ajax发布后,如何使用JQuery .load()方法发送POST请求 - On success of ajax post, how to send a POST request with JQuery .load() method 成功的ajax请求进入错误回调而不是成功 - Successful ajax request which goes in error callback instead of success 如何检查 AJAX 请求的成功/错误回调? - How can I check the success/error callbacks of an AJAX request? Ajax 请求返回 200 OK,但触发了错误事件而不是成功 - Ajax request returns 200 OK, but an error event is fired instead of success 为什么来自 AJAX 请求的响应数据出错而不成功? - Why response data from AJAX request comes in error and not success? Angular 5在第一次编译时出现错误(错误:TS2339),但在成功编译后一切正常 - Angular 5 have error on first compile (error: TS2339), but after success compilation all works fine 编辑Backbone Ajax成功方法以添加自定义错误处理 - Edit Backbone Ajax Success Method to Add in Custom Error Handling Angular $ http.get请求未运行成功或错误功能 - Angular $http.get request not running success or error functions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM