• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AngularJS: referencing functions in the scope?

 
Joe Harry
Ranch Hand
Posts: 10114
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recently started exploring on AngularJS and picked up a book to read and practice. I however have a beginner question?

The controller is as follows:



And the markup fragment looks in the following manner:



Now what would the following mean?



What is inferred by doing $scope.worldsPercentage?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's creating a function in the scope. So you need to call it like a function, not reference it as a property. (What's inferred by your expression is the function itself, not the result of calling it).
 
Joe Harry
Ranch Hand
Posts: 10114
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:That's creating a function in the scope. So you need to call it like a function, not reference it as a property. (What's inferred by your expression is the function itself, not the result of calling it).


Thanks! that made it partially clear to me! What would then the countryPopulation parameter mean?

May be one other question. Not sure though if this is the relevant forum to ask! I'm looking forward to build a web app and the way I want it is to provide a REST API that the UI will communicate with. For this purpose, I have the following path's:

1. Use AngularJS / NodeJS as the UI layer and expose the Scala backend using Spray REST API layer.
2. Use Play and expose the Scala backend using the Play Controller model.

Any suggestions on which approach I should go for? What I'm thinking is that I would still need to use some Javascript for DOM manipulation with my second approach. I then have to invest my time and effort to learn Play along with a Javascript framework. What would the suggestion be?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Harry wrote:
Thanks! that made it partially clear to me! What would then the countryPopulation parameter mean?

Whatever value you pass to it. The function will compute what percentage of the total populations that country is. Don't get distracted by all the AngularJS context... it's all just JavaScript, so functions don't change they way they work.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And please don't gang up multiple questions in the same topic. Ask your new question in a new topic.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic