如何仅在用户登录到站点时显示菜单列表。但截至目前,用户能够通过直接提供URL来查看菜单。如果用户登录那么只有他能够看到菜单列表和所有。可以任何人检查这一点。 HTML代码:只有在登录后才能在angularjs中显示特定页面
<html lang="en" ng-app="accountantApp">
<div class="container jumbotron" ng-init= "getAddressInfo()" ng-controller="AddressInfoController" id="homejumbotron">
<div class="col-sm-12 primary">
<div class="col-sm-2"><a href="#" class="ui-btn ui-shadow ui-corner-all personal">PERSONALINFO</a></div>
<div class="col-sm-2"><a href="login.php" class="ui-btn ui-shadow ui-corner-all">LOGOUT</a></div>
</div>
JS:
var app = angular.module('accountantApp', ['ui.bootstrap']);
app.controller('AddressInfoController', function($scope,$http,$timeout) {
$scope.submitAddressInfo = function(isValid, user) {
if (isValid) {
console.log("address info::"+$scope.user);
$http({
method : 'POST',
url : '../model/addaddressinfo.php',
headers : {
'Content-Type': 'application/json'
},
data : {'addressinfo': $scope.user, 'action': 'Save'}
}).success(function(data, status, headers) {
console.log("Response data:"+ data.error);
if (data.success != undefined && data.success != '')
{
console.log("inside success");
window.location.href = "income_source.php";
$scope.getTemplate("ADDRESSINFO");
$scope.user = '';
}
else
{
$scope.error = data.error;
}
}).error(function(data, status, headers) {
window.location.href = "error.html";
console.log("Error data::::"+ data);
alert("Error occured while creating address info:"+status);
});
}
else{
$scope.submitted = true;
alert("Fill the form.");
return;
}
};
假设你有一个的LoginController在你的范围(例如'isAuthenticated')添加认证标志,一旦用户登录这个标志设置为true 。在你的意见中添加'ng-hide'指令到你的链接并使用isAuthenticated标志的值 – Sherlock
@EuphoriaGrogi我不明白你在说什么 – user5751258
@EuphoriaGrogi你能不能更新我一个例子 – user5751258