registerpanel.js

angular.module('homepage').
directive('registerpanel', function() {
	return {
		controller: 'registerPanelController',
		restrict: 'E',
		replace: true,
		transclude: true,
		templateUrl: 'components/content-components/login/registerpanel.html'
	};
}).
controller('registerPanelController', function ($location, $scope, $timeout, Server) {
	// FB Pixel: Track when a user expresses interest in your offering
	fbq('track', 'Lead');
	var params = $location.search();
	console.log(params);

	$scope.data = {};
	$scope.invite = { code: ''};
	$scope.isRegisterMessageVisible = false;
	$scope.isInviteMessageVisible = false;

	// Hide registration panel, if param 'hasinvite' set to true
	$scope.hasInvite = params.hasinvite;
	$scope.register = function () {
		console.log($scope.data);
		Server.register($scope.data)
		.success(function (data) {
			console.log(data);
			if(data.success) {

			}
			$scope.data = {};
			$scope.message = data.message;
			$scope.isRegisterMessageVisible = true;
			$timeout(function () {
				$scope.isRegisterMessageVisible = false;
			}, 3000);
		});
	};
	$scope.checkInviteCode = function () {
		Server.checkInvite($scope.invite)
		.success(function (data) {
			console.log(data);
			$scope.invite.code = '';
			if(data.success) {
				$timeout(function () {
					$location.path('/signup');
				}, 2000);
			}
			$scope.message = data.message;
			$scope.isInviteMessageVisible = true;
			$timeout(function () {
				$scope.isInviteMessageVisible = false;
			}, 3000);
		});
	};
});