cancel
Showing results for 
Search instead for 
Did you mean: 

Alternative to arrow-function =>

Former Member
0 Kudos

screenshot-36-li.jpgscreenshot-37.pngscreenshot-38.pngHi guys,

So I have the following problem: We are developing an app. In that app you can look for certain objects by typing the ID of that object. My goal is that if you type in the number, but accidentally add a space (' ') or anything additional (letters etc.), which the number itself doesn't contain, it should still find the number and show the object to you.

Now our SAPUI Verison doesn't support ES6 so the arrow function doesn't work for me here. Is there any alternative to that so it works?

First screenshot you can see the code.

Second Screenshot is the dialog to type in and look for a certain number.

Third screenshot than is the object and the number.

I hope you can help me. Thanks!

boghyon
Product and Topic Expert
Product and Topic Expert
0 Kudos

Let us know if the answers were helpful. 🙂 Otherwise, feel free to leave a comment if something is unclear

Accepted Solutions (0)

Answers (3)

Answers (3)

boghyon
Product and Topic Expert
Product and Topic Expert
0 Kudos

In addition to my previous answer, I'd like to suggest, if applicable, to replace the TextArea control with the MaskInput:

content: new /*sap.m.*/MaskInput({ // Instead of TextArea
  mask: "999999999999", // Max. 12 digits
  placeholder: "Meldungsnummer eingeben"
}),

This would eliminate the need to filter out all non-digit characters (liveChange handler).

The "9" in MaskInput represents numbers by default.

API reference: sap/m/MaskInput

boghyon
Product and Topic Expert
Product and Topic Expert
0 Kudos

> Now our SAPUI Verison doesn't support ES6 so the arrow function doesn't work

Sure, you can always replace arrow functions with function declarations like this:

arrsText.forEach(function(item, index) {
  // ...
}.bind(this));

But the error indication in the code editor is not due to the lack of support by the framework but due to the missing ESlint parameter in your project settings which needs to be added:

With ES6 syntax, you now have to transpile the code before deploying as explained by Wouter's blog post (in case the target browser is not being actively developed, such as IE11) or apply this workaround to deploy the app without transpiling it.

maheshpalavalli
Active Contributor
0 Kudos

Hi Tatyana,

Check this blog, which will remove the eslint errors from webide

https://blogs.sap.com/2017/11/01/next-generation-javascript-in-ui5-using-sap-web-ide/

BR,

Mahesh