Javascript AngularJS将值绑定到NgShow和NgHide
我正在尝试使用数组来显示和隐藏使用ng show和ng hide的div。它似乎并没有始终如一地发挥作用。当我使用控制台检查这些值时,它们是正确的,但是它们没有正确地反映在HTML中Javascript AngularJS将值绑定到NgShow和NgHide,javascript,angularjs,Javascript,Angularjs,我正在尝试使用数组来显示和隐藏使用ng show和ng hide的div。它似乎并没有始终如一地发挥作用。当我使用控制台检查这些值时,它们是正确的,但是它们没有正确地反映在HTML中 <div class="directionsContent" ng-show="showvars.directions" ng-hide="!showvars.directions"> <h1 class="directionsTitle">DIRECTIONS TO:</h1
<div class="directionsContent" ng-show="showvars.directions" ng-hide="!showvars.directions">
<h1 class="directionsTitle">DIRECTIONS TO:</h1>
<h3>{{directions.title}}</h3>
<div id="directionsPanel"></div>
</div>
下面是代码,不幸的是它没有一个有效的示例
不要同时使用
ng show
和ng hide
。。。它们都做同样的事情,只是语义颠倒了。谢谢。我忘了删除jQuery语句。如果你想要信用,你可以把你的评论作为答案,我会给你信用。所以评论没有帮助?那么这不是一个答案:D
$scope.ShowMobile = function (showsection) {
console.log(showsection)
for (prop in $scope.showvars) {
console.log(prop, $scope.showvars[prop])
if (showsection != "return" && showsection != "info") {
$scope.showvars[prop] = false;
}
}
switch (showsection) {
case "explore":
$scope.showvars.explore = true;
break;
case "directions":
$scope.showvars.explore = true;
$scope.showvars.directions = true;
break;
case "tourlist":
$scope.showvars.explore = true;
$scope.showvars.tourlist = true;
break;
case "tourdetail":
$scope.showvars.explore = true;
$scope.showvars.tourdetail = true;
break;
case "tour":
$scope.showvars.explore = true;
$scope.showvars.tour = true;
break;
case "nearby":
$scope.showvars.explore = true;
$scope.showvars.nearby = true;
break;
case "info":
$scope.showvars.explore = false;
$scope.showvars.info = true;
break;
case "search":
$scope.showvars.search = true;
break;
case "return":
$scope.showvars.explore = true;
$scope.showvars.info = false;
$scope.showvars.search = false;
break;
default:
break;
}
console.log($scope.showvars)
}