File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 1010 var User = datastore . defineResource ( 'user' ) ;
1111
1212 angular . module ( 'firebase-example' , [ ] )
13- . controller ( 'firebaseCtrl' , function ( $scope ) {
13+ . controller ( 'firebaseCtrl' , function ( $scope , $timeout ) {
1414 $scope . add = function ( user ) {
15- User . create ( user ) ;
15+ $scope . creating = true ;
16+ User . create ( user ) . then ( function ( ) {
17+ $scope . creating = false ;
18+ $timeout ( ) ;
19+ } , function ( ) {
20+ $scope . creating = false ;
21+ } ) ;
1622 } ;
1723 $scope . remove = function ( user ) {
18- User . destroy ( user . id ) ;
24+ $scope . destroying = user . id ;
25+ User . destroy ( user . id ) . then ( function ( ) {
26+ delete $scope . destroying ;
27+ $timeout ( ) ;
28+ } ) ;
1929 } ;
2030 $scope . $watch ( function ( ) {
2131 return User . lastModified ( ) ;
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ <h3 class="panel-title">Users</h3>
2323 < div class ="list-group ">
2424 < div class ="list-group-item " data-ng-repeat ="user in users track by user.id ">
2525 < div class ="pull-right ">
26- < button class ="btn btn-sm btn-danger " data-ng-click ="remove(user) ">
26+ < button class ="btn btn-xs btn-danger " data-ng-click ="remove(user) " data-ng-disabled =" destroying === user.id ">
2727 Delete
2828 </ button >
2929 </ div >
@@ -33,7 +33,7 @@ <h3 class="panel-title">Users</h3>
3333 < form id ="user-form " name ="user-form " data-ng-submit ="add({ name: fCtrl.name }) ">
3434
3535 < input class ="form-control " type ="text " data-ng-model ="fCtrl.name " id ="name " name ="name "
36- placeholder ="Enter a name and press enter "/>
36+ placeholder ="Enter a name and press enter " data-ng-disabled =" creating " />
3737 < input type ="submit " class ="hidden "/>
3838 </ form >
3939 </ div >
You can’t perform that action at this time.
0 commit comments