@@ -29,12 +29,13 @@ import {IComment} from "../../interfaces";
2929 <div class="comment-content">
3030 <div class="comment-tabnav">
3131 <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>
3434 </nav>
3535 </div>
3636 <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>
3839 </div>
3940 <div class="comment-body" ng-bind-html="$ctrl.comment.text"></div>
4041 </div>
@@ -56,17 +57,19 @@ class CommentController {
5657
5758 constructor ( ) {
5859 this . editMode = ! this . comment . id ;
59- this . comment . inputTags = angular . copy ( this . comment . tags ) ;
6060 }
6161
6262 edit ( ) {
6363 this . editMode = true ;
6464 this . commentCopy = angular . copy ( this . comment ) ;
65+ this . comment . inputTags = angular . copy ( this . comment . tags || [ ] ) ;
6566 }
6667
6768 save ( ) {
6869 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+ }
7073 ( this . onAdd || angular . noop ) ( ) ;
7174 }
7275
0 commit comments