「AngularJS」ngBindHtmlディレクティブのサンプル

説明
<要素 ng-bind-html="{条件式}">
some code
</要素>
htmlコード

<head>
<meta charset="utf-8">
<script src="/angular.js/1.4.6/angular.min.js"></script>
<script src="/angular.js/1.5.0-beta.0/angular-sanitize.min.js"></script></head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<p ng-bind-html="myText"></p>
</div>

JSコード

<script>
var app = angular.module("myApp", ['ngSanitize']);
app.controller("myCtrl", function($scope) {
    $scope.myText = "This Programe is: <h1>Test Data</h1>";
});
</script>

 

AngularJS

Posted by arkgame