@@ -29,12 +29,13 @@ import {IComment} from "../../interfaces";
29
29
<div class="comment-content">
30
30
<div class="comment-tabnav">
31
31
<nav class="tabnav-tabs" role="tablist">
32
- <button type="button" class="btn-link tabnav-tab write- tab js-write-tab selected" role="tab ">Write</button>
33
- <button type="button" class="btn-link tabnav-tab preview- tab js-preview-tab" role="tab ">Preview</button>
32
+ <button type="button" class="btn-link tabnav-tab" role=" tab" ng-class="{ selected: !$ctrl.previewMode}" ng-click="$ctrl.previewMode = false ">Write</button>
33
+ <button type="button" class="btn-link tabnav-tab" role=" tab" ng-class="{selected: $ctrl.previewMode}" ng-click="$ctrl.previewMode = true ">Preview</button>
34
34
</nav>
35
35
</div>
36
36
<div class="write-content">
37
- <textarea placeholder="Leave a comment" class="comment-textarea" ng-model="$ctrl.comment.text"></textarea>
37
+ <textarea placeholder="Leave a comment" class="comment-textarea" ng-model="$ctrl.comment.text" ng-hide="$ctrl.previewMode"></textarea>
38
+ <p ng-bind-html="$ctrl.comment.text || 'Nothing to preview'" ng-show="$ctrl.previewMode"></p>
38
39
</div>
39
40
<div class="comment-body" ng-bind-html="$ctrl.comment.text"></div>
40
41
</div>
@@ -56,17 +57,19 @@ class CommentController {
56
57
57
58
constructor ( ) {
58
59
this . editMode = ! this . comment . id ;
59
- this . comment . inputTags = angular . copy ( this . comment . tags ) ;
60
60
}
61
61
62
62
edit ( ) {
63
63
this . editMode = true ;
64
64
this . commentCopy = angular . copy ( this . comment ) ;
65
+ this . comment . inputTags = angular . copy ( this . comment . tags || [ ] ) ;
65
66
}
66
67
67
68
save ( ) {
68
69
this . editMode = ! this . comment . id ;
69
- this . comment . tags = this . comment . inputTags . map ( ( el :any ) => el . text ) ;
70
+ if ( this . comment . inputTags ) {
71
+ this . comment . tags = this . comment . inputTags . map ( ( el :any ) => el . text ) ;
72
+ }
70
73
( this . onAdd || angular . noop ) ( ) ;
71
74
}
72
75
0 commit comments