Last active
December 16, 2015 12:29
-
-
Save hui/5435247 to your computer and use it in GitHub Desktop.
kindeditor for angularjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('kindeditor', []).directive 'kindeditor', -> | |
| require: '?ngModel' | |
| link: (scope, elm, attr, ngModel)-> | |
| unless ngModel then return | |
| ngModel.$render = (value)-> | |
| unless ngModel.editor | |
| csrfToken = $('meta[name=csrf-token]').attr('content') | |
| csrfParam = $('meta[name=csrf-param]').attr('content') | |
| extraParams = {} | |
| extraParams[csrfParam] = csrfToken | |
| ke = KindEditor.create $(elm[0]), basePath: '/kindeditor/', uploadJson: '/upload', extraFileUploadParams: extraParams, afterChange: ()-> | |
| if ke | |
| ngModel.$setViewValue(ke.html()) | |
| ngModel.editor = ke | |
| ngModel.editor.html(ngModel.$viewValue) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment