title: Delay displaying UI in cross platform app on ng-if
body: <p>I have a cross platform app built using Monaca and AngularJS.</p>
  
  <p>On some screens I display a generic view, and then display certain sections based on the outcome of some calculations/lookups using <strong><em>ng-if</em></strong> and <strong><em>ng-include</em></strong>.</p>
  
  <p>E.g. for the Login screen, I display a generic view, while in my controller I check whether the user has logged in before. Depending on the outcome of this lookup, I either show a Welcome message OR prompt the user to Login.</p>
  
  <p>Below is a abbreviated version of the generic <em>login</em> view.</p>
  
  <pre><code>&lt;div&gt;
      &lt;ons-page&gt;
          &lt;ons-scroller &gt;
              &lt;!-- Show if user not logged in --&gt;
              &lt;div ng-if="!loggedIn"&gt;
                  &lt;div ng-include="'login/login-details.html'"&gt;&lt;/div&gt;
              &lt;/div&gt;
              &lt;!-- Show if user logged in --&gt;
              &lt;div ng-if="loggedIn"&gt;
                  &lt;div ng-include="'login/login-confirmation.html'"&gt;&lt;/div&gt;
              &lt;/div&gt;
          &lt;/ons-scroller&gt;
      &lt;/ons-page&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is working fine but the issue is that the first <strong><em>ng-if</em></strong> is always shown - even just for a second - while the controller checks if the user is logged in and then sets the value of <strong><em>loggedIn</em></strong>. So the user always sees the login prompt until the controller returns true or false on the variable <strong><em>loggedIn</em></strong>.</p>
  
  <p>The boolean value for <strong><em>loggedIn</em></strong> is just defined but not initialed in the controller. It only gets initiated once the lookup has been done.</p>
  
  <p>How can I stop both the <strong><em>ng-include</em></strong> s from displaying till I know which one to display? </p>
  
  <p>I can create another <strong><em>ng-if</em></strong> but it seems long winded and inefficient.</p>