• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

AngularJS: referencing functions in the scope?

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic