如何在ng-view中注入HTML页面



我在任何教程中发现的所有代码都是注入消息字符串而不是html页面。我如何注入html页面使用ng-view?SPA的结构是2个链接"添加"one_answers"查看"Add注入Add .html, View注入View.html

使用

ng-bind-html

你的HTML代码看起来像

<div ng-controller="ExampleController">
 <p ng-bind-html="myHTML"></p>
</div>

你可以通过以下方式bin html

angular.module('bindHtmlExample', ['ngSanitize'])
.controller('ExampleController', ['$scope', function($scope) {
  $scope.myHTML =
     'I am an <code>HTML</code>string with ' +
     '<a href="#">links!</a> and other <em>stuff</em>';
}]);

建议绑定html而不是htmlpage.

最新更新