Create a simple login / $digest already in progress

I’m trying to interact w/ my backend using Ionic’s $http-object. Unfortunately, I don’t know how to transition from login / registration to my main app properly, since I’m always getting a “$digest already in progress”-error. Can anyone help me here?

Also, is there like a standardized way to store something like a session_id after a successful login?


.controller('loginCtrl', function($scope, $http, $rootScope, $ionicLoading, $state) {
        $scope.doLogin = function() {
            var email = $; 
            var password = $scope.loginData.password; 
            if (!email || !validateEmail(email) || !password) {
                alert('err missing login');
            } else {
                var requestData = {
                    email: email,
                    password: password
                    template: 'Loading...'
                $"", requestData, {
                    headers: {'Content-Type': 'application/json'}
                }).success(function(responseData) {
                    alert('Login successful!');
                }).error(function(err) {
                    if (err.error && err.error.length >= 1) {
                }).finally(function() {

That error typically means you are manually doing a $scope.$digest() or $scope.$apply() somewhere in your code. Is that being done anywhere else in your application?