compile angularjs template

Solutions on MaxInterview for compile angularjs template by the best coders in the world

showing results for - "compile angularjs template"
Francesca
26 May 2016
1 angular.module("myModule", [])
2                .controller("myController", ['$scope', '$compile', function ($scope, $compile) {
3                    $scope.txt = "<b>SampleTxt</b>";
4                    $scope.submit = function () {
5                        var html = $compile($scope.txt)($scope);
6                        angular.element(document.getElementById("display")).append(html);
7                    }
8                }]);
9
10<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
11<body ng-app="myModule" >
12    <div ng-controller="myController">
13        <textarea ng-model="txt" ></textarea>
14        <input type="button" value="submit" ng-click="submit()" />
15        <div id="display"></div>
16    </div>
17</body>