aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes AngularJS: referencing functions in the scope? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "AngularJS: referencing functions in the scope?" Watch "AngularJS: referencing functions in the scope?" New topic
Author

AngularJS: referencing functions in the scope?

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9384
    
    2

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?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

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).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9384
    
    2

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

Joined: Jan 10, 2002
Posts: 61226
    
  66

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

Joined: Jan 10, 2002
Posts: 61226
    
  66

And please don't gang up multiple questions in the same topic. Ask your new question in a new topic.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: AngularJS: referencing functions in the scope?