You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
angular-contenteditable/src/radians/contenteditable.coffee

17 lines
426 B
CoffeeScript

angular.module('radians.contenteditable', [])
.directive('contenteditable', ->
require: 'ngModel',
link: (scope, elm, attrs, ctrl) ->
# view -> model
view_to_model = ->
scope.$apply ->
ctrl.$setViewValue elm.html()
elm.bind 'blur', view_to_model
elm.bind 'input', view_to_model
elm.bind 'change', view_to_model
# model -> view
ctrl.$render = -> elm.html ctrl.$viewValue
)