<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>angular</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src=""></script>
<script src=""></script>
<link href="">
<script src="" type="text/javascript"></script>
</head>
<body ng-app="app">
<script type="text/javascript">
var app = angular.module("app",[]);
</script>
<div>
<div>
ng-switch的使用
</div>
<div ng-controller="sw">
<div ng-init="a=2">
<ul ng-switch on="a">
<li ng-switch-when="1">1</li>
<li ng-switch-when="2">2</li>
<li ng-switch-default>other</li>
</ul>
</div>
<div>
<button ng-click="a=1">test</button>
<button ng-click="a=2">test</button>
<button ng-click="a=3">test</button>
</div>
</div>
<script type="text/javascript">
app.controller("sw", function($scope) {
});
</script>
</div>
</body>
</html>
ng-src和ng-href;
复制代码 代码如下: