成熟丰满熟妇高潮XXXXX,人妻无码AV中文系列久久兔费 ,国产精品一国产精品,国精品午夜福利视频不卡麻豆

您好,歡迎來(lái)到九壹網(wǎng)。
搜索
您的當(dāng)前位置:首頁(yè)通過(guò)AngularJS實(shí)現(xiàn)動(dòng)態(tài)編譯添加到dom中的方法

通過(guò)AngularJS實(shí)現(xiàn)動(dòng)態(tài)編譯添加到dom中的方法

來(lái)源:九壹網(wǎng)

本文實(shí)例講述了AngularJS實(shí)現(xiàn)動(dòng)態(tài)編譯添加到dom中的方法。分享給大家供大家參考,具體如下:

在使用angularjs 時(shí),希望通過(guò)動(dòng)態(tài)構(gòu)建angular模版,再通過(guò)angular進(jìn)行展示。

使用 方法如下:

<html ng-app="app">
<head>
 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
 <script src="assets/angular.min.js"></script>
 <script src="assets/js/jquery.min.js"></script>
 <script src="assets/js/handlebars.min.js"></script>
 <script src="assets/Handlebars.helper.js"></script>
 <script >
 var app=angular.module("app",[]);
 app.controller('ctrl', ['$scope','$compile',function($scope,$compile){
 $scope.userName='RAY';
 $scope.test = function test(){
 console.log('你好:' +$scope.userName);
 }
 //通過(guò)$compile動(dòng)態(tài)編譯html
 var html="<button ng-click='test()'>{{userName}}</button>";
 var template = angular.element(html);
 var mobileDialogElement = $compile(template)($scope);
 angular.element(document.body).append(mobileDialogElement);
 }]);
 </script>
</head>
<body ng-controller="ctrl">
</body>
</html>
var html="<button ng-click='test()'>{{userName}}</button>";

這種代碼就是angular模版,通過(guò)angularjs的編譯器進(jìn)行編譯,就能夠訪問(wèn)到angular scope中的對(duì)象數(shù)據(jù)。

Copyright ? 2019- 91gzw.com 版權(quán)所有 湘ICP備2023023988號(hào)-2

違法及侵權(quán)請(qǐng)聯(lián)系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市萬(wàn)商天勤律師事務(wù)所王興未律師提供法律服務(wù)