我使用Angular $ route进行导航突出显示,但突出显示没有显示。这是导航的代码......
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body ng-app="myApp">
<div ng-controller="myController" class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li ng-class="{active: $route.current.activetab == 'home'}"><a href="index.html">Home</a></li>
<li ng-class="{active: $route.current.activetab == 'audio'}"><a href="audio">Audio</a></li>
<li ng-class="{active: $route.current.activetab == 'bio'}"><a href="bio">Artist Bio</a></li>
<li ng-class="{active: $route.current.activetab == 'contact'}"><a href="contact">Contact</a></li>
</ul>
</div>
</body>
</html>
以下是带有$ route ...的AngularJS控制器的代码。
app.controller("myController", function($scope,$http, $route) {
$http.post('myform.php')
.then(function successCallback(response){
$scope.detail = response.data;
if($scope.detail){
console.log("success");
} else{
console.log("no data");
}
}, function errorCallback(response) {
console.log("error");
});
$scope.$route = $route;
});
答案 0 :(得分:0)
您是否包含了js库?
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular-route.js"></script>
您是否将ngRoute注入角度模块?
var app = angular.module("myApp", ['ngRoute']);