您好,登錄后才能下訂單哦!
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>test</title> <style> .red{ background-color: red; } .black{ background-color: black; } </style> <script src="js/angular.js"></script> <script type="application/javascript"> (function(angular) { 'use strict'; angular.module('myApp', []) .controller('firstController', function firstController($scope,$sce) { $scope.witchColor = {red:true,black:false}; $scope.changeColor = function(){ if($scope.witchColor.red){ $scope.witchColor.red = false; }else{ $scope.witchColor.red = true; } if($scope.witchColor.black){ $scope.witchColor.black = false; }else{ $scope.witchColor.black = true; } } $scope.teststyle={color:'yellow'}; $scope.address= "http://www.baidu.com"; $scope.idshow = true; $scope.idshow = false; $scope.mySwitch = 3; $scope.t1 = "test1"; $scope.t2 = "test2"; $sce.trustAsHtml("<a ); $scope.myhtml1= $sce.trustAsHtml("<a );//$sce 中的trustAsHtml來信任這個html內容 }); })(window.angular);//主模塊 window.onload = function(){ var myAppdiv = document.getElementById('myApp22'); angular.bootstrap(myAppdiv,['myApp']) //動態的綁定主mudule的html作用范圍 } </script> </head> <body > <div id="myApp22"> <div ng-controller="firstController"> <div ng-class="witchColor">test</div> <input type="button" value="changeColor" ng-click="changeColor()"/> <div ng->test</div> <a ng-href="`address`">www</a> <div ng-show="idshow">您</div> <div ng-switch on="mySwitch"> <span ng-switch-default> 0</span> <span ng-switch-when="1">1</span> <span ng-switch-when="2">2</span> <span ng-switch-when="3">3</span> </div> <div ng-bind-template="`t1``t2`"></div><!--綁定多個--> <div ng-bind-html="myhtml1" >1212</div> <!--把這個div中的innerHtml綁定到變量myhtml--> </div> </div> </body> </html>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。