angular-bind-html-compile icon indicating copy to clipboard operation
angular-bind-html-compile copied to clipboard

The directive does not work on iOS cordova app

Open sarahsga opened this issue 8 years ago • 2 comments

The $compile in the directive does not work on iOS cordova app, and prevents the HTML from getting rendered at all.

sarahsga avatar Dec 20 '16 20:12 sarahsga

Thanks for reporting. Do you mind sharing some code? You're also welcome to submit a PR.

wytrych avatar Dec 21 '16 09:12 wytrych

@wytrych I solved it.

Here is the HTML that I wanted to bind to a scope variable:

facts.html

<div id="content" bind-html-compile="dynamicHTML" >

facts.controller.js

$http.get(url)
        .then(
        function(response){
          $scope.dynamicHTML = response.data;
        }

The content div, as a result, rendered nothing at all on Safari(web) and iOS (cordova)

The line in the bind-html-compile directive that was causing the rendering issue was Line 22 in angular-bind-html-compile.js $compile(element.contents())(compileScope); It prevented anything from rendering at all.

I wanted to enable click on just one anchor tag inside $scope.dynamicHTML. I replaced Line 22 above with the following code: $compile(element.contents().find( "a" ))(compileScope);

That solved it.

sarahsga avatar Jan 28 '17 14:01 sarahsga