Are ES6 arrow functions incompatible with Angular?

后端 未结 2 1676
半阙折子戏
半阙折子戏 2020-12-17 16:43

Here\'s a normal ES5 function in my Angular code which works:

app.run(function($templateCache){ $templateCache.put(\'/some\',\'thing\') });

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-17 17:03

    I tried another variation which worked: (x)=>… (instead of x=>…)

    app.run(($templateCache) => $templateCache.put('/some','thing'));
    

    I guess it needs parentheses for some reason

提交回复
热议问题