2

Edit like suggested from str:

I want to create an object in a panel, and this object should contain a (or two) function(s). This Object will be handed over to a component (I am programming with angularjs, so I will hand it over via bindings) so I can configure my panel on the "clientcomponent" that opens that panel...

If I am trying to do that, IntelliJ gives the Error warning that a ',' is expected


I am trying to incorporate an arrowfunction inside of an js object.. but intellij doesn't like my approach.

I'm searching for sth like this:

this.api = {
        showContent=(this.config)=> {
          //do sth
    }

Is that possible?

1
  • Maybe you should explain in words what you are trying to do. Your code example is just invalid and not clear at all. Commented Nov 15, 2016 at 9:05

1 Answer 1

2

JS Object structure:

this.api = {
    showContent: true
};

Now to add arrow function try this

this.api = {
    showContent: config => {
        return true;
    }
};

Similar to old style

this.api = {
    showContent: function (config) {
        return true;
    } 
}
Sign up to request clarification or add additional context in comments.

3 Comments

Tried that, this.config doesn't work. But it works with 'showConntent: config =>' I would upvote, but the downvote of my question prevents that... thanks for your answer!
Keep in mind, when having 0 or more than 1 parameter, parenthesis are required. so: showContent: () => { and showContent: (a, b) => {. Other than that, great answer!
this.config is not a valid parameter name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.