Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 9169

Is this a proper way to get controller object?

$
0
0

Hi guys,

 

On the UI, I have a button to which I have attached a controller method to handle.

But in that method, "this" points to the button triggering the press event. But I want to get controller object, so I figure out a way to achieve that.

Here's the code:

 

sap.ui.controller("view.Players",{     me:{},          onInit:function(){       me = this;// in init , I assign this(controller object) to me property.       },          // this is the press event handler     addPlayer:function(){          me.dosomething();       }
)}

I just don't know whether there's a easier way to achieve that?

And I'm kinda confused by my own code, why is it possible to access me in the addPlayer method?


Viewing all articles
Browse latest Browse all 9169

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>