Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am trying to do addapt the contenteditable directive I foud on angularjs website (http://docs.angularjs.org/guide/concepts#directives).

My problem is that if I change the value inside the contenteditable div inside my controller, the scope value is updated but the value in the div isn't. I would like to be able to do something like this in my main controller :

$scope.content = $scope.content.concat("added text");

This updated the $scope.content but it does not update the contenteditable div. And so, if I click in the div to edit it, my modification is gone.

In order to make it work, I would have to call ctrl.$render from my controller but I can't find any documentation on what is this 4th parameter of the link function.

Does anyone have an idea what this 'ctrl' parameter represents and if by change some know how to solve my problem :)

share|improve this question
 
The 4th parameter is the controller specified in the require parameter. In this case ctrl is an instance of the ngModelController. –  Mark Rajcok Mar 20 at 18:27
1  
The forms page and the NgModelController page have contenteditable examples, but not the directives page. Which page are you looking at? –  Mark Rajcok Mar 20 at 18:30
 
I am using the one I the forms page except I have removed the line "ctrl.$setViewValue(elm.html());" which I have replaced by ctrl.$render(). –  Tagazok Mar 20 at 18:49
 
But I have just tried the directive from the NgModelController page and it works like expected :) Thanks! –  Tagazok Mar 20 at 18:56

1 Answer

As of this writing (3/20/2013), there are two problems with the Plunker from the forms page:

  1. missing form-example.
    HTML should be: <html ng-app="form-example2">
  2. contentEditable should be contenteditable.
    HTML should be: <div contenteditable ng-model="content">Some content</div>

Plunker with link to append to $scope.content in the controller.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.