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.
26 lines
656 B
CoffeeScript
26 lines
656 B
CoffeeScript
angular.module('radians.contenteditable', [])
|
|
.directive('contenteditable', ->
|
|
require: 'ngModel',
|
|
link: (scope, elm, attrs, ctrl) ->
|
|
# view -> model
|
|
elm.bind 'blur', ->
|
|
console.log elm
|
|
console.log "blur()"
|
|
scope.$apply ->
|
|
ctrl.$setViewValue elm.html()
|
|
|
|
elm.bind 'input', (e) ->
|
|
console.log 'input', e
|
|
t = elm.html()
|
|
console.log 'elm contents', t
|
|
scope.$apply ->
|
|
ctrl.$setViewValue t
|
|
|
|
# model -> view
|
|
ctrl.$render = (v) ->
|
|
console.log @
|
|
console.log "model: #{@$modelValue}, view: #{@$viewValue}"
|
|
console.log "$render()", v
|
|
elm.html ctrl.$viewValue
|
|
)
|