在模型angularJS中保存html标签



我想保存字符串

<div class="Page" contenteditable="true"></div>
$scope.Pages = [''];

在angularJS但是当我在HTML中使用ng-repeat时,它显示为字符串。我希望它是一个div而不是一个字符串

我认为你应该使用ngBindHtml(https://docs.angularjs.org/api/ng/directive/ngBindHtml)

看看这个链接也很有帮助:https://docs.angularjs.org/api/ng/service/$sce

请检查

http://jsfiddle.net/Shital_D/75wbb0b2/2/

执行以下步骤1。下载angular-sanitize.js2. 代码

var app = angular.module('myApp', ["ngSanitize"]);
app.controller('myController', function($scope) {
    $scope.html = ['<div class="text-color">Your html code</div>',
                    '<div class="text-color">2nd div</div>',
                    '<div class="text-color">3rd div </div>'
                  ];
});

最新更新