1

I can't see where is the syntax problem here :

x = ()->new TranformService()
angular.module('rcMovable').factory (  "transformService", x)

When there is no problem there

x = ()->new TranformService()
angular.module('rcMovable').factory  "transformService", x

Forget about Angular stuff for the moment, I have :2:58: error: unexpected ','

1 Answer 1

4

You cannot put a space between a method name and the parenthesis used to invoke it. If you do, the parenthesis are no longer part of the function invocation, they're for order-of-operations on the arguments to the function.

Consider a few examples of valid and invalid syntax:

  • x() is a valid invocation with no arguments
  • x () is an invalid invocation of x with one argument: (). Because () is not a valid expression, this is a syntax error.
  • x (name: "bob") or x (->3 * 3), 4 are both valid invocations, because the (...) is a valid expression
  • x(a, b) is again a valid invocation of x with two arguments
  • x (a, b) is an invalid invocation of x with one argument: (a, b). Again, (a, b) is not itself a valid expression, so this is a syntax error.

In your case, you're trying to invoke .factory with one argument: ("transformService", x), which is not a valid expression.

What you've written is essentially this:

a = ("transformSerice", x) # invalid syntax
factory(a)
Sign up to request clarification or add additional context in comments.

Comments

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.