Skip to content

Commit

Permalink
Merge pull request outsideris#106 from linagora/issue-105
Browse files Browse the repository at this point in the history
  • Loading branch information
outsideris committed Jan 15, 2016
2 parents bb4e990 + 81936a8 commit ae2ddb4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/angular-summernote.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ angular.module('summernote', [])

if (ngModel) {
ngModel.$render = function() {
element.summernote('code', ngModel.$viewValue || '');
if (ngModel.$viewValue) {
element.summernote('code', ngModel.$viewValue);
} else {
element.summernote('empty');
}
};
}

Expand Down
15 changes: 15 additions & 0 deletions test/angular-summernote.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,21 @@ describe('Summernote directive', function() {
}
}, 200);
});

it('should empty summernote when model is empty', function() {
// given
scope.text = 'Hello World';
var element = $compile($('<summernote ng-Model="text"></summernote>').appendTo(document.body))(scope);
scope.$digest();

// when
scope.text = '';
scope.$digest();

// then
expect(element.summernote('code')).to.not.equal('');
expect(element.summernote('isEmpty')).to.equal(true);
});
});

describe('callbacks', function() {
Expand Down

0 comments on commit ae2ddb4

Please sign in to comment.