J
J
JIakki2015-09-21 11:19:53
Angular
JIakki, 2015-09-21 11:19:53

What is the problem with the controller?

There is a controller

app.controller 'UserCtrl', ["localData", (localData) ->
  self = this
  self.data = localData.user// данные
  self.icons = localData.icons // данные
]

39aa87d9eef14a22acd763772e94551f.png
here User = localData.icons, not User.icons = localData.icons
But if you add one more property
app.controller 'UserCtrl', ["localData", (localData) ->
  self = this
  self.data = localData.user
  self.icons = localData.icons
  self.name = 'some name'
]

everything is
274a19619e264bb790a64298f63f46de.png
fine then thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-09-21
@JIakki

deal with closures in your coffeescript. They implicitly return values, as far as I remember.
You do not register a controller in Angular, but a controller constructor. And constructors in js can return anything if you explicitly return.
To understand what went wrong, take a look at the generated code. I'm sure there will be something along the lines of:
return self.icons = localData.icons.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question