<!doctypehtml><htmllang="en"><head><metacharset="UTF-8"><title>test</title><style>.red{background-color:red;}.black{background-color:black;}</style><scriptsrc="js/angular.js"></script><scripttype="application/javascript">(function(angular){'usestrict';angular.module('myApp',[]).controller('firstController',functionfirstController($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("<ahref='http://benohead.com'>benohead.com</a>");$scope.myhtml1=$sce.trustAsHtml("<ahref='http://benohead.com'>benohead.com</a>");//$sce中的trustAsHtml来信任这个html内容});})(window.angular);//主模块window.onload=function(){varmyAppdiv=document.getElementById('myApp22');angular.bootstrap(myAppdiv,['myApp'])//动态的绑定主mudule的html作用范围}</script></head><body><divid="myApp22"><divng-controller="firstController"><divng-class="witchColor">test</div><inputtype="button"value="changeColor"ng-click="changeColor()"/><divng->test</div><ang-href="`address`">www</a><divng-show="idshow">您</div><divng-switchon="mySwitch"><spanng-switch-default>0</span><spanng-switch-when="1">1</span><spanng-switch-when="2">2</span><spanng-switch-when="3">3</span></div><divng-bind-template="`t1``t2`"></div><!--绑定多个--><divng-bind-html="myhtml1">1212</div><!--把这个div中的innerHtml绑定到变量myhtml--></div></div></body></html>