Opening specific page at an event

I am very new to ionic framework. I am making an application which will go to specific url and get some json if the user is logged in else it will return a json with an error code if the user is not logged in. Now if json contains the error code then user should be presented with a login screen. How do I open the login page if user is not authenticated.

This should get you in the right direction.

Basically have a value in scope defining that the user is not logged in, var loggedIn=false;. Then using $htttp, request that data and change the value of that variable based on the success.

$http({method: 'GET', url: '/someUrl'})
 .success(function(data, status, headers, config) {
      // this callback will be called asynchronously
      // when the response is available
    .error(function(data, status, headers, config) {
      // called asynchronously if an error occurs
      // or server returns response with an error status.