亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

angularjs中使用ng-bind-html和ng-include的實(shí)例

 更新時間:2017年04月28日 09:59:55   投稿:jingxian  
下面小編就為大家?guī)硪黄猘ngularjs中使用ng-bind-html和ng-include的實(shí)例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

下面這個例子,往div標(biāo)簽內(nèi)添加html內(nèi)容:

<!doctype html>
<html ng-app="myApp">
<head>
 <meta charset="UTF-8">
 <title>demo</title>
 <script type="text/javascript" src="lib/angularjs/angular.min.js" charset="utf-8"></script>
 
</head>
<body ng-controller="ctrl">
  <div ng-bind-html="myText"></div>
<script>
var app = angular.module('myApp',[]);
app.controller("ctrl",function($scope,$sce){
  $scope.myText = $sce.trustAsHtml("<b>粗體內(nèi)容</b><br/><i>斜體內(nèi)容</i>");
});
</script>
</body>
</html>

注意在賦值時需要將html用$sce.trustAsHtml作一個處理,不然頁面會報(bào)錯,無法輸出內(nèi)容。

下面是ng-include的使用示例,跟上面的例子差不多,只是把要添加的html內(nèi)容放到一個文件中:

<!doctype html>
<html ng-app="myApp">
<head>
 <meta charset="UTF-8">
 <title>demo</title>
 <script type="text/javascript" src="lib/angularjs/angular.min.js" charset="utf-8"></script>
 
</head>
<body ng-controller="ctrl">
  <div ng-include="'demo1_1.html'"></div>
<script>
var app = angular.module('myApp',[]);
app.controller("ctrl",function($scope){});
</script>
</body>
</html>

demo1_1.html

<b>粗體內(nèi)容222</b><br/><i>斜體內(nèi)容222</i>

以上這篇angularjs中使用ng-bind-html和ng-include的實(shí)例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論