ng-hideを使用してテーブルの列を非表示にしようとしています。ユーザーがログインする前に、列がユーザーに表示されていないはずです。ログイン後、非表示の列が表示されます。しかし、今では、ユーザーがシステムにログインしていない場合、ng-hideプロパティを使用した後、テーブル全体が非表示になります。この問題の解決方法を知ることができますか?AngularJS:ng-hideが動作しない
これは私の部分のhtmlコードです:
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th ng-show="noteEnabled">Note</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="movie in movies | pagination: currentPage * entryLimit | limitTo: entryLimit" data-ng-class="{'selected':selectedFilm.film_id===movie.film_id}" >
<td>
{{movie.title}}
</td>
<td>
{{movie.description}}
</td>
<td data-ng-click="selectFilmDetails($event,movie)" ng-show="movie.noteEnabled" >
{{movie.comment}}
</td>
</tr>
</tbody>
</table>
これは私のcontroller.jsコードです:
.controller('AllMovieController',
[
'$scope',
'dataService',
'$location',
function ($scope, dataService, $location){
$scope.noteEnabled = false;
$scope.movies = [ ];
$scope.movieCount = 0;
$scope.currentPage = 0; //current page
$scope.entryLimit = 20; //max no of items to display in a page
var getAllMovie = function() {
dataService.getAllMovie().then(
function (response) {
var userName=dataService.getSessionService('user');
$scope.movieCount = response.rowCount + ' movies';
if(userName){
$scope.movies = response.data;
$scope.userLogin = dataService.getSessionService('user');
$scope.userLoginEmail = dataService.getSessionService('userEmail');
$scope.showSuccessMessage = true;
$scope.successMessage = "All movie Success";
$scope.noteEnabled = true;
}
},
function (err){
$scope.status = 'Unable to load data ' + err;
}
); // end of getStudents().then
};
$scope.numberOfPages = function(){
return Math.ceil($scope.movies.length/$scope.entryLimit);
};
//------------------
$scope.selectFilmDetails = {};
$scope.selectFilmDetails = function ($event,movie) {
$scope.selectFilmDetails = movie;
$location.path('/filmDetails/' + movie.film_id);
}
getAllMovie();
}
]
)
最初に私がfalseにnoteEnabled
を設定し、ユーザーがある場合、セッションに確認してくださいログインするとnoteEnabled
がtrueになります。前もって感謝します。
クライアント側のソリューションはlook'n'feelを制御する機能に過ぎないことに注意してください。ビジターからの情報を守りたい場合は、サーバー側のソリューションを作成する必要があります。 –