You can use the $compile service. return $compile($scope.ngHtmlSnippet)($scope);
Em quarta-feira, 14 de maio de 2014 09h56min21s UTC-3, Yves Kircher escreveu: > > *Hi, * > > *How can i bind a html code into a div, that has angular features inside ?* > > *Example:* > > > <script type="text/javascript" src=" > http://ci.angularjs.org/job/angular.js-angular-master/ws/build/angular.js > "></script> > <script type="text/javascript" src=" > http://ci.angularjs.org/job/angular.js-angular-master/ws/build/angular-sanitize.js > "></script> > > <html ng-app> > <head> > <script> > function Ctrl($scope, $sce) { > $scope.var = "My Headline"; > $scope.ngHtmlSnippet = "Headline:<h1>{{ var }}</h1>"; > $scope.deliberatelyTrustDangerousSnippet = function() { > return $sce.trustAsHtml($scope.ngHtmlSnippet); > }; > } > </script> > </head> > <body ng-controller="Ctrl"> > <textarea ng-model="ngHtmlSnippet" cols="60" rows="3"></textarea> > <div ng-bind-html="deliberatelyTrustDangerousSnippet()"></div> > </body> > </html> > -- 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 angular+unsubscr...@googlegroups.com. To post to this group, send email to angular@googlegroups.com. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.