1

I am new to angularjs. I am trying to make an custom element directive loaded from a model. If I use this directive in the HTML file works, but what I want to do is use this directive in a model. It is possible to trigger the directive after define the model ?

JS:

window.app = angular.module('myapp', ['ngSanitize']);

app.directive("myWidget", function() {
  return {
    restrict: 'E',
    template: "<p>Hello World</p>",
  };
});

app.controller('page', ['$scope', '$sce', function($scope, $sce) {

  $scope.myhtml = $sce.trustAsHtml("<my-widget></my-widget>")

}]);

HTML:

<div ng-app="myapp">
  <div ng-controller="page">
    <my-widget></my-widget>
    <div ng-bind-html="myhtml"></div>
  </div>
</div>
Viseo
  • 167
  • 2
  • 9
  • 1
    See http://stackoverflow.com/questions/19726179/how-to-make-ng-bind-html-compile-angularjs-code – PSL May 27 '15 at 20:25

0 Answers0