Javascript $location.path()提供完整URL,而不是Meteor中的相对路径
当路径不是Javascript $location.path()提供完整URL,而不是Meteor中的相对路径,javascript,angularjs,meteor,angular-meteor,Javascript,Angularjs,Meteor,Angular Meteor,当路径不是/hideBanner时,我试图显示一个横幅div。这是一个使用angularui:angularui路由器软件包,使用angularui和Meteor制作的网页 问题:但是$location.path()给了我http://localhost:3000/hideBanner而不是/hideBanner 为什么要给出完整的URL angular.module('myApp').controller('BannerCtrl', function($scope, $location) {
/hideBanner
时,我试图显示一个横幅div。这是一个使用angularui:angularui路由器软件包,使用angularui和Meteor制作的网页
问题:但是$location.path()给了我http://localhost:3000/hideBanner
而不是/hideBanner
为什么要给出完整的URL
angular.module('myApp').controller('BannerCtrl', function($scope, $location) {
$scope.showBanner = function() {
console.log($location.path());
return $location.path() != '/hideBanner';
}
})
index.ng.HTML的HTML
<div class="banner" ng-controller='BannerCtrl' ng-show='showBanner'></div>
这太奇怪了,你使用什么样的路由?@Michelem我正在使用常规的ui.router
mmm你能移动console.log($location.path())吗
是否在showBanner
函数之外,只是为了尝试返回正确的值?(我不认为)那么这个ng show='showBanner'
应该是ng show='showBanner()'
@Michelem Yes更改为ng show='showBanner()
导致它现在工作:)