SAPUI5/OpenUI5: Model attachRequestCompleted in onInit Function
<p>I've got two models defined in my <em>Component.js</em>. One is a list of all contacts and the other is only the logged in contact. Now i want to check in my controller if the logged in contact is already existing in the list of all contacts. I compare the registrationToken from the list agains the token from the logged in contact. But when i loop through the list the length is 0 because of asynchronous communication.
I saw the <em>attachRequestCompleted</em> function but now i got another problem... the onInit-function is already finished when my attach-function is fill my view-Model.. </p>

<pre><code>onInit : function(){
    var gLocalContact = sap.ui.getCore().getModel("gLocalContact");
    var gRemoteContacts = sap.ui.getCore().getModel("gRemoteContacts");

    gRemoteContacts.attachRequestCompleted( function() {
        ... if ... setProperty to gLocalContact.getProperty("/registrationToken")...
        console.log("I should be the first log to get the data in view");
    });

    console.log("I should be the second log!");
    this.getView().setModel(gLocalContact, "localContact");
}
</code></pre>

<p>The first log in the attach-function should be first because there i define some data to <em>gLocalContact</em> which i need in my view. Another problem is that i have no access to my gLocalContact variable....</p>