Fiddle: BrandonTilley.com: AngularJS Example

AngularJS 1.1.5 Includes jQuery

by BinaryMuse

HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js"></script>

JavaScript

// http://stackoverflow.com/questions/18690804/insert-and-parse-html-into-view-using-angularjs

app = angular.module('myApp', []);

app.run(function($rootScope, $compile, $rootElement) {
  // We'll create a new scope to use as the context for the view.
  $scope = $rootScope.$new();
  $scope.model = [{name: 'first'}, {name: 'second'}, {name: 'third'}];
    
  // Calling `$compile(html)` returns a function that, when called with
  // a context object, links the compiled HTML to the given context (e.g.
  // binds scope-based expressions in the view to the passed in scope).
  var html = "<div ng-repeat='m in model'>{{m.name}}</div>";
  var linkingFunction = $compile(html);
  var elem = linkingFunction($scope);
    
  // You can then use the DOM element like normal.
  $rootElement.append(elem);
});