Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Binding ng-directives

techies
Kilo Expert

Hi All,

I am binding a number box to a html page and require the number box to use some ng-direvtives.

I am doing it as follows.

var bind = $sce.trustAsHtml("<input step=\"0.01\" ng-model=\"model\" ng-change=\"c.uiActionFunction('action')\" type=\"number\"   "id=\"number\"/>")

<div ng-bind-html="bind"></div>

The number box works fine and I can retrieve the value however the ng directives don't work. After searching online its because you have to compile the variable to be able to use the directives but I don't see how this can be done in service now.

Does anyone have any suggestions on how to do this?

Thanks for any help.

6 REPLIES 6

Hi lurii,


It will have to be a $compile use since there is never a preset amount of ng-directive's needed. I have been unable to get $compile working in service portal. Do you happen to have an example of this?


Thanks,


Roni Khalil


Hi Roni,



I have created a little example that demonstrates the concept. I added few comments there to help you understand the idea: https://codepen.io/anon/pen/qXarWN.


In an essence there is a directive called my-bind-html that binds and compiles custom HTML template to the scope.



Hope this helps.


Iurii