Skip to main content
added 4 characters in body
Source Link
henryhw
  • 63
  • 1
  • 6

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"><pcontroller="modalPopup"><div ng-bind-html="renderHtml(message)"></p><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 :)

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"><p ng-bind-html="renderHtml(message)"></p></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 :)

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 :)

Source Link
henryhw
  • 63
  • 1
  • 6

How to render from a html file using Angularjs ng-bind-html

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"><p ng-bind-html="renderHtml(message)"></p></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 :)