我试图隐藏到<a>
标记,然后使用isLoggedIn()
函数在登录时显示它们,但是<a>
标记无论如何都显示。
HTML(pool-details.html)
<header class="hero-unit" id="banner" ng-include="'components/header/header.html'"></header>
<div ng-include="'components/navbar/navbar.html'"></div>
<div class="container"> <hr>
<div class="col-md-3 left-col-3">
<div ng-include="'../components/sidebar/sidebar.html'"></div>
</div>
<div class="col-md-5">
<div class="details-pic">
<img class="pool-details-pic" ng-src="{{ pool.picture }}"/>
</div>
</div>
<div class="col-md-4">
<h3 class="details-name">{{ pool.name }}</h3>
<p class="details-info">Varenummer: {{ pool.number }}</p>
<p class="details-info">Lager status: {{ pool.inStock }}</p>
<p class="details-info">Dimensioner: {{ pool.width }}m x {{ pool.length }}m x {{ pool.height }}m</p>
<hr>
<p class="details-info">{{ pool.info }}</p>
</div>
<div class="col-md-12">
<a ng-show="'isLoggedIn()'" ng-click="deleteProduct(pool)" class="delete-product">Slet</a>
<a ng-show="'isLoggedIn()'" ng-click="editProduct(pool)" class="edit-product">Opdater</a>
</div>
</div>
<footer class="footer" ng-include="'components/footer/footer.html'"></footer>
控制器(pool-details.controller.js)
'use strict';
angular.module('welldanaJavascriptApp')
.controller('poolDetailsCtrl', function ($scope, $stateParams, $state, poolService, Auth) {
$scope.pool = {};
poolService.find($stateParams.poolId, function(pool) {
$scope.pool = pool;
});
$scope.deleteProduct = function(product){
poolService.delete(product._id, function(){
$state.go('pools');
});
};
});
尽管我尚未登录,但我无法确定为什么
<a>
标记仍会显示。我正在为Angular Fullstack应用程序使用Passport插件。 最佳答案
ng-show="'isLoggedIn()'"
它会计算'isLoggedIn()'字符串,并且该字符串将始终为true,因此应重构为
ng-show="isLoggedIn()"
关于javascript - AngularJS-ng-show无法正常工作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30257266/