File tree Expand file tree Collapse file tree 6 files changed +112
-1
lines changed Expand file tree Collapse file tree 6 files changed +112
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import './home';
14
14
import './profile' ;
15
15
import './article' ;
16
16
import './services' ;
17
+ import './auth' ;
17
18
18
19
19
20
// Create and bootstrap application
@@ -25,7 +26,8 @@ const requires = [
25
26
'app.home' ,
26
27
'app.profile' ,
27
28
'app.article' ,
28
- 'app.services'
29
+ 'app.services' ,
30
+ 'app.auth'
29
31
] ;
30
32
31
33
// Mount on window for testing
Original file line number Diff line number Diff line change
1
+ function AuthConfig ( $stateProvider , $httpProvider ) {
2
+ 'ngInject' ;
3
+
4
+ $stateProvider
5
+
6
+ . state ( 'app.login' , {
7
+ url : '/login' ,
8
+ controller : 'AuthCtrl as $ctrl' ,
9
+ templateUrl : 'auth/auth.html' ,
10
+ title : 'Sign in'
11
+ } )
12
+
13
+ . state ( 'app.register' , {
14
+ url : '/register' ,
15
+ controller : 'AuthCtrl as $ctrl' ,
16
+ templateUrl : 'auth/auth.html' ,
17
+ title : 'Sign up'
18
+ } ) ;
19
+
20
+ } ;
21
+
22
+ export default AuthConfig ;
Original file line number Diff line number Diff line change
1
+ class AuthCtrl {
2
+ constructor ( $state ) {
3
+ 'ngInject' ;
4
+
5
+ this . title = $state . current . title ;
6
+ this . authType = $state . current . name . replace ( 'app.' , '' ) ;
7
+
8
+ }
9
+
10
+ submitForm ( ) {
11
+ this . isSubmitting = true ;
12
+
13
+ console . log ( this . formData ) ;
14
+ }
15
+ }
16
+
17
+ export default AuthCtrl ;
Original file line number Diff line number Diff line change
1
+ < div class ="auth-page ">
2
+ < div class ="container page ">
3
+ < div class ="row ">
4
+
5
+ < div class ="col-md-6 offset-md-3 col-xs-12 ">
6
+ < h1 class ="text-xs-center " ng-bind ="::$ctrl.title "> </ h1 >
7
+ < p class ="text-xs-center ">
8
+ < a ui-sref ="app.login "
9
+ ng-show ="$ctrl.authType === 'register' ">
10
+ Have an account?
11
+ </ a >
12
+ < a ui-sref ="app.register "
13
+ ng-show ="$ctrl.authType === 'login' ">
14
+ Need an account?
15
+ </ a >
16
+ </ p >
17
+
18
+ < form ng-submit ="$ctrl.submitForm() ">
19
+ < fieldset ng-disabled ="$ctrl.isSubmitting ">
20
+
21
+ < fieldset class ="form-group " ng-show ="$ctrl.authType === 'register' ">
22
+ < input class ="form-control form-control-lg "
23
+ type ="text "
24
+ placeholder ="Username "
25
+ ng-model ="$ctrl.formData.username " />
26
+ </ fieldset >
27
+
28
+ < fieldset class ="form-group ">
29
+ < input class ="form-control form-control-lg "
30
+ type ="email "
31
+ placeholder ="Email "
32
+ ng-model ="$ctrl.formData.email " />
33
+ </ fieldset >
34
+
35
+ < fieldset class ="form-group ">
36
+ < input class ="form-control form-control-lg "
37
+ type ="password "
38
+ placeholder ="Password "
39
+ ng-model ="$ctrl.formData.password " />
40
+ </ fieldset >
41
+
42
+ < button class ="btn btn-lg btn-primary pull-xs-right "
43
+ type ="submit "
44
+ ng-bind ="::$ctrl.title ">
45
+ </ button >
46
+
47
+ </ fieldset >
48
+ </ form >
49
+ </ div >
50
+
51
+ </ div >
52
+ </ div >
53
+ </ div >
Original file line number Diff line number Diff line change
1
+ import angular from 'angular' ;
2
+
3
+ // Create the module where our functionality can attach to
4
+ let authModule = angular . module ( 'app.auth' , [ ] ) ;
5
+
6
+ // Include our UI-Router config settings
7
+ import AuthConfig from './auth.config' ;
8
+ authModule . config ( AuthConfig ) ;
9
+
10
+
11
+ // Include controllers
12
+ import AuthCtrl from './auth.controller' ;
13
+ authModule . controller ( 'AuthCtrl' , AuthCtrl ) ;
14
+
15
+
16
+ export default authModule ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ class HomeCtrl {
4
4
5
5
this . appName = AppConstants . appName ;
6
6
7
+
7
8
}
8
9
9
10
You can’t perform that action at this time.
0 commit comments