Ready to start development
diff --git a/mCordPortal/src/app/view/login/login.html b/mCordPortal/src/app/view/login/login.html
index 426a2e9..178f21b 100644
--- a/mCordPortal/src/app/view/login/login.html
+++ b/mCordPortal/src/app/view/login/login.html
@@ -2,17 +2,17 @@
<div class="container login">
<div class="login-wrapper">
<h3 class="text-center">Subscriber Portal</h3>
- <form ng-submit="login()">
+ <form ng-submit="vm.login()">
<div class="form-group">
- <input class="form-control" ng-model="email" type="text" placeholder="email" required>
+ <input class="form-control" ng-model="vm.email" type="text" placeholder="email" required>
</div>
<div class="form-group">
- <input class="form-control" ng-model="password" type="password" placeholder="password" required>
+ <input class="form-control" ng-model="vm.password" type="password" placeholder="password" required>
</div>
<div class="form-group">
<button class="btn btn-primary btn-block" type="submit">
Log In
- <div class="loader small reverse inline" ng-show="loading === true"></div>
+ <div class="loader small reverse inline" ng-show="vm.loading === true"></div>
</button>
</div>
<div class="form-group" ng-show="error">
diff --git a/mCordPortal/src/app/view/login/login.js b/mCordPortal/src/app/view/login/login.js
index 170abcf..348fc42 100644
--- a/mCordPortal/src/app/view/login/login.js
+++ b/mCordPortal/src/app/view/login/login.js
@@ -17,31 +17,36 @@
(function () {
'use strict';
- angular.module('cordLogin', [])
- .controller('CordLoginCtrl', function ($log, $scope, $resource, $location, $window, User) {
+ angular.module('mCord')
+ .directive('cordLogin', function ($log, $location, User) {
- $scope.page.curr = 'login';
- $scope.loading = false;
+ return {
+ restrict: 'E',
+ templateUrl: 'app/view/login/login.html',
+ controllerAs: 'vm',
+ controller: function(){
- $scope.login = function () {
- if ($scope.email && $scope.password) {
- //getResource($scope.email);
- $scope.loading = true;
- User.login($scope.email, $scope.password)
- .then(function(user){
- $location.url('/');
- })
- .catch(function(e){
- $scope.error = true;
- })
- .finally(function(){
- $scope.loading = false;
- });;
+ this.loading = false;
- $scope.shared.login = $scope.email;
+ this.login = () => {
+ if (this.email && this.password) {
+ this.loading = true;
+ User.login(this.email, this.password)
+ .then(() => {
+ $location.url('/');
+ })
+ .catch(() => {
+ this.error = true;
+ })
+ .finally(() => {
+ this.loading = false;
+ });
+ }
+ };
+
+ $log.debug('Cord Login Ctrl has been created.');
}
- };
+ }
- $log.debug('Cord Login Ctrl has been created.');
});
}());