我正在尝试更改导航菜单条目的颜色,以指示哪个是当前页面。但是location.path
返回一个空字符串。我没有其他错误。
var mflfApp = angular.module("mflfApp", []);
mflfApp.controller('navController', ['$scope', '$location', function ($scope, $location) {
$scope.isActive = function (destination) {
// This function should indicate if the path provide in the destination correspond to the current
// locaiton. This is then used to highlight an option in the navigation menu
// $location.path(); contains a blank string. But does not throws an error.
return destination === $location.path();
}
}]);
return destination === $location.path();
如果您只是通过,则在destination
变量中得到的字符串是:
return destination === $location.path(destination);
希望它对您有用。