Re: [angular.js] ng-bind-html-unsafe, dynamic form, model issues

2,053 views
Skip to first unread message

Oliver Batchelor

unread,
Jul 4, 2012, 1:19:20 AM7/4/12
to ang...@googlegroups.com
Hi Jeremy,

I gave it a go using a $compile directive, have a look here:

http://jsfiddle.net/Saulzar/ctyfg/25/

The second text "Property Two:" doesn't show up, not sure why that is
exactly - but it works at least.

Cheers,
Oliver

On Wed, Jul 4, 2012 at 1:27 AM, Jeremy Snyder <jeremy...@gmail.com> wrote:
> I am having a problem with adding in form elements dynamicly from a
> configuration obtained from a server. I am using ng-bind-html-unsafe, and
> the form renders perfectly, but I can't seem to figure out how to tie in an
> event handler so that when the element loads into the page, the form
> elements are compiled into the model.
>
> jsFiddle example: http://jsfiddle.net/j_snyder/ctyfg/
>
> Notice that property two and three don't update the model. I tried
> bootstrapping the parent div element, but I suspect a race condition, and
> don't know how to tie in an event handler to when the dom has been updated
> with the new html. Any help is appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/angular/-/9cvuHeWVYfgJ.
> To post to this group, send email to ang...@googlegroups.com.
> To unsubscribe from this group, send email to
> angular+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/angular?hl=en.

Oliver Batchelor

unread,
Jul 5, 2012, 9:17:32 AM7/5/12
to ang...@googlegroups.com
I guess normally you could generate the form from some data loaded as
JSON, probably more the 'angular way'.

Something like this:

http://jsfiddle.net/Saulzar/ctyfg/27/

Glad to help. Learning plenty myself.

Oliver

On Fri, Jul 6, 2012 at 12:56 AM, j.snyder <jeremy...@gmail.com> wrote:
> Oliver,
>
> Nice work! Would be nice if the bind html unsafe did a compile on the
> section, since that is essentially what you are doing, but this looks like a
> great option. Thanks again.
>
> Also, I noticed that if I started with an HTML tag and not Property Two, it
> rendered the whole block. Not sure why, but it works:
> http://jsfiddle.net/j_snyder/ctyfg/26/
>
> This seems like it could be a pretty useful solution for others too, is
> there a reason why there isn't a built in ability to do this?
> https://groups.google.com/d/msg/angular/-/HJfRh3r7t4UJ.
Reply all
Reply to author
Forward
0 new messages