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.
17 lines
426 B
CoffeeScript
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
|
|
)
|