1
1
notes . controller ( 'dashboardCtrl' , function dashboardCtrl ( $scope , $window , $http ) {
2
2
3
- $scope . updateNote = false ;
3
+ $scope . editNote = false ;
4
4
$scope . createNote = true ;
5
5
$http . post ( '/getNote' , { "email" : sessionStorage . user_email } )
6
6
. success ( function ( data ) {
@@ -38,7 +38,7 @@ notes.controller('dashboardCtrl', function dashboardCtrl($scope, $window, $http)
38
38
html += '<a class="col-md-2" id="deleteNote" ng-click="deleteNote(' + data . _id + ')">Delete</a>' ;
39
39
html += '</div>' ;
40
40
html += '<h1>' + $scope . noteHeading + '</h1>' ;
41
- html += '<div class="col-md-12">' + $scope . note + '</div>' ;
41
+ html += '<div class="col-md-12" id="noteBody" >' + $scope . note + '</div>' ;
42
42
angular . element ( '#notes' ) . append ( html ) ;
43
43
$scope . name = data . firstname + data . lastname ;
44
44
$ ( '#myModal' ) . modal ( 'hide' ) ;
@@ -61,7 +61,7 @@ notes.controller('dashboardCtrl', function dashboardCtrl($scope, $window, $http)
61
61
}
62
62
63
63
$scope . getNoteById = function ( noteId ) {
64
- $scope . updateNote = true ;
64
+ $scope . editNote = true ;
65
65
$scope . createNote = false ;
66
66
$http . post ( '/getNoteById' , { "noteId" : noteId } )
67
67
. success ( function ( data ) {
@@ -79,14 +79,15 @@ notes.controller('dashboardCtrl', function dashboardCtrl($scope, $window, $http)
79
79
$http . post ( '/updateNote' , { "noteId" : $scope . noteId , "noteTitle" : $scope . noteHeading , "noteBody" : $scope . note } )
80
80
. success ( function ( data ) {
81
81
$ ( '#myModal' ) . modal ( 'hide' ) ;
82
- $scope . updateNote = true ;
82
+ angular . element ( '#' + $scope . noteId ) . children ( 'h1' ) . html ( $scope . noteHeading ) ;
83
+ angular . element ( '#' + $scope . noteId ) . children ( '#noteBody' ) . html ( $scope . note ) ;
84
+ $scope . editNote = true ;
83
85
$scope . createNote = false ;
84
86
} )
85
87
. error ( function ( data ) {
86
88
alert ( "Cannot be updated" ) ;
87
- $scope . updateNote = true ;
89
+ $scope . editNote = true ;
88
90
$scope . createNote = false ;
89
91
} ) ;
90
92
}
91
-
92
93
} ) ;
0 commit comments