I did it like this:
In the css:
[placeholder-text]:not(:focus):empty:before {
content: attr(placeholder-text);
float: left;
margin-left: 2px;
color: rgba(200,200,200,1);
}
the element looks like this:
<div contenteditable=true placeholder-text="Description"></div>
it works fine!
On Wednesday, October 17, 2012 6:38:35 AM UTC+2, Anuj wrote:
>
> I wanted to add placeholder text in a contenteditable div using the
> ngModelController. The requirement is that placeholder text appear every
> time there is no value in the div. I am unable to get it to work properly.
>
>
> Failure points:
>
> 1. If I type something in the div and then delete it, the html of the
> element shows <br>. If I use .text instead, it ignores new line
> characters. Hence, I don't always get the placeholder text. This is not
> an angularJS relevant issue, but I would appreciate help.
> 2. If I clear out the model, the user entered text remains in the div,
> but my logic also causes the placeholder to appear.
>
> http://jsfiddle.net/anujpshah/nnXmb/
>
> Can someone recommend a better approach to doing this.
>
> Thanks,
>
> Anuj
>
>
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.