3

I'm using ng-bind-html to render a html code to my page, but my code is too long. So I put it in a HTML file. How can I do that? This is my HTML and Js controller.My page include this:

<div ng-controller="modalPopup"><div ng-bind-html="renderHtml(message)"></div></div>

JS controller:

angular.module('mainApp', []).
controller('modalPopup', function($scope, $http,$sce) {
    $scope.renderHtml = function(value) {
     return $sce.trustAsHtml(value);
  };
  $scope.message = '';
});

I want to put a big block of code HTML to $scope.message How can I do that. Thanks all :)

1 Answer 1

1

If you want to include content from the file into your HTML then you should use ngInclude:

<div ng-controller="modalPopup"><p ng-include="'path/to/file.html'"></p></div>
Sign up to request clarification or add additional context in comments.

1 Comment

It's important to have the single quote in the include path. Thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.