Inject new angular js controller with html dynamically after page loaded
<p>I have been working on a angular js site, which get the data from webservice/api. One api returns html and angular js code to dynamically add conroller or whatever new angular component we want to add new.
This string will come in api response</p>

<pre><code>&lt;div id="homecontainer" class="flex-center p-page" loader style="overflow:hidden;"&gt;
    &lt;div class="column-1"&gt;
        &lt;div class="grid m-0 col-xs-12"&gt;
            &lt;div ng-repeat="Widget in V3Widgets track by $index" class="grid-item"&gt;
                &lt;div class="grid-sizer"&gt;&lt;/div&gt;
             {{Widget}}
            &lt;/div&gt;


        &lt;/div&gt;
        &lt;div ng-controller="WelcomeController"&gt;
            {{greeting}}
        &lt;/div&gt;
        &lt;script&gt;
            var app = angular.module('demo', [])
                //RestService is Other Module Which is Already Working fine 
            .controller('WelcomeController', function ($scope,RestService) {
                $scope.greeting = 'Welcome!';
            });
            angular.bootstrap(document, ['demo']);
        &lt;/script&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>Now i have a directive to bind this string to page</p>

<pre><code>&lt;renderdynamicwidgethtml ng-if="Widget.Id==null &amp;&amp; Widget.Html!=null" html="Widget.Html"/&gt;
</code></pre>

<p>Directive's js</p>

<pre><code>.directive('renderdynamicwidgethtml', ['$compile', function ($compile) {
    return function (scope, element, attrs) {
        scope.$watch(
          function (scope) {
              return scope.$eval(attrs.html);
          },
          function (value) {
              element.html(value);
              $compile(element.contents())(scope);
          }
       );
    };
}])
</code></pre>

<p><code>scope.$eval</code> should convert the string to angular components, but it failed with this error.</p>

<blockquote>
  <p>[ng:btstrpd] <a href="http://errors.angularjs.org/1.3.17/ng/btstrpd?p0=document" rel="noreferrer">http://errors.angularjs.org/1.3.17/ng/btstrpd?p0=document</a></p>
</blockquote>