Angular write the navigation. Self-taught angular has been for some time.
<!doctype html>
<meta charset= "UTF-8" >
<title>Document</title>
<script src= '. /angular-1.3.9/angular.js ' ></script>
<style>
*{
List-style:none;
margin:0;
padding:0;
}
. listbox{
width:600px;
height:30px;
margin:0 Auto;
border:1px solid #ccc;
box-shadow:2px 2px 3px #333;
}
. ListBox li{
width:100px;
Float:left;
height:30px;
line-height:32px;
Text-align:center;
Cursor:pointer;
Font-weight:bold;
Color: #333;
font-family: ' Microsoft ya Black ';
border-radius:15px;
}
. ListBox li.cour{
Background:skyblue;
Color: #fff;
text-shadow:1px 1px 1px #333;
}
</style>
<body ng-app= ' app ' >
<ul ng-controller= ' cont ' class= ' listbox ' >
<li ng-repeat= ' I in List ' ng-click= ' cour ($index) ' ng-class= ' {true: ' Cour ', False: '} [I.isclick] ' >{{i.text}}< /li>
</ul>
<script>
var data=[{text: ' Home ', Isclick:false},{text: ' News '},{text: ' Project ', Isclick:false},{text: ' Cooperate ', Isclick: False},{text: ' About Us ', Isclick:false},{text: ' More ', isclick:false}];
var app=angular.module (' APP ', []);//define Angular module
App.controller (' cont ', function ($scope) {//angular Controller
$scope. list=data;//Injection Data
$scope. list[0].isclick=true;//First Add Style
$scope. Cour=function (index) {
Here with JS implementation, without JS with angular how to achieve
for (Var i=0;i< $scope. list.length;i++) {
$scope. list[i].isclick=false;//when clicked, no other style is added.
}
$scope. List[index].isclick=true;//ng-click when the current add style
}
})
</script>
</body>
Ng-click the time to let the unselected do not add style, with angular need to use what?
I am here directly with JS implementation, and I feel the data in the Isclick:false, with variables should also be possible!
Angular implementing navigation Ng-click switching