var app = angular.module("wevivu", ['ngMaterial']);
app.version = '/api/v1/'

app.controller('LoginController', function ($scope, $mdDialog) {

    $scope.showLoginAndSignupForm = function (ev) {

        $mdDialog.show({
            controller: DialogController,
            templateUrl: '/pages/login_register.tmpl.html',
            parent: angular.element(document.body),
            targetEvent: ev,
            clickOutsideToClose: false
        }).then(function () {

        });
    };

    function DialogController($scope, $mdDialog, $http, $window, $interval) {

        $scope.hide = function () {
            $mdDialog.hide();
        };

        $scope.cancel = function () {
            $mdDialog.cancel();
        };

        $scope.login = function (user) {
            $http.post(app.version + 'session', user).then(function(response){
                if(response.data.status == 'success'){
                    $window.location.reload();
                }
                else {
                    $scope.loginError.show = true;
                    $scope.loginError.data = response.data.data.error;
                }
            });
        };

        $scope.register = function (user) {
            $http.post(app.version + 'users', user).then(function (response) {
                if (response.data.status == 'success') {
                    $window.location.reload();
                }
                else {
                    $scope.loginError.show = true;
                    $scope.loginError.data = response.data.data.error;
                }
            });
        };
    }
});
@@ -558,16 +558,15 @@
 w, $
-interval
+timeout
 ) %7B%0A
@@ -1193,32 +1193,74 @@
 nction (user) %7B%0A
+            $scope.registerError = false;%0A
             $htt
@@ -1404,32 +1404,36 @@
    $
-window.location.reload()
+scope.registerSuccess = true
 ;%0A  
@@ -1449,34 +1449,40 @@
     
- %7D%0A
      
-           else %7B%0A
+$timeout(function () %7B%0A    
     
@@ -1504,37 +1504,38 @@
  $scope.
-loginError.show = tru
+registerSuccess = fals
 e;%0A     
@@ -1553,76 +1553,108 @@
     
-$scope.loginError.data = response.data.data.error;%0A                %7D
+%7D, 5000);%0A                %7D%0A            %7D, function () %7B%0A                $scope.registerError= true;
 %0A   

update notication