Tablo sütunlarımı gizlemek için angularjs $ yayın özelliğini kullanmaya çalışıyorum. Veri yayınlanırsa, tablo sütunu gösterilmeli, tablo sütunu gizlenmelidir. Şu anda kodumu çalıştırırsam, giriş yaptıktan sonra oturum açma kullanıcı adımı işleve yayınladım ama hala tüm masam göstermiyor. Çözmenin bir yolunu biliyor olabilirim.
Benim controller.js kodudur:
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th ng-show="noteEnabled">Notes</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="movie in movies | pagination: currentPage * entryLimit |
limitTo: entryLimit">
<td>
{{movie.title}}
</td>
<td>
{{movie.description}}
</td>
<td data-ng-click="selectFilmDetails($event,movie)" ng-show="noteEnabled" >
{{movie.comment}}
</td>
</tr>
</tbody>
</table>
Bu yayınlanan kontrol kodu:
.controller('LoginController',
[
'$scope',
'dataService',
'$location',
'$window',
'$rootScope',
function ($scope, dataService, $location, $window, $rootScope){
$scope.check_login = function($event,userID,passwd){
dataService.login(userID,passwd).then(
function (response){
if(response.result.status=='ok'){
$scope.user = response.user;
$rootScope.$broadcast("passuser", $scope.user);
$location.path('#/home');
//$window.location.reload();
}else{
$scope.message = response.result.message;
}
},
function (err) {
$scope.status = 'unable to connect to data' + err;
}
);
}//end of function check_login
}
]
)
Daha önce bu zaman kısmi HTML kodu
.controller('AllMovieController',
[
'$scope',
'dataService',
'$location',
'$rootScope',
function ($scope, dataService, $location, $rootScope){
$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) {
$scope.$on("passuser", function ($event, data){
if(data){
$scope.movies = response.data;
$scope.showSuccessMessage = true;
$scope.successMessage = "All movie Success";
$scope.noteEnabled = true;
}else{
$scope.movies = response.data;
$scope.noteEnabled = false;
}
});
},
function (err){
$scope.status = 'Unable to load data ' + err;
}
); // end of getStudents().then
};
$scope.numberOfPages = function(){
return Math.ceil($scope.movies.length/$scope.entryLimit);
};
getAllMovie();
}
]
)
olan
kullanıcının oturum açıp açmadığını kontrol etmek için kullanılan oturum, ancak şimdi kullanıcı adıma contro geçmek için yayın kullanıyorum ller. Ve aynı ben bu denetleyiciye kullanıcı adını geçmeye çalıştı çalışmaz. Bu konuda gerçekten yardıma ihtiyacım var. Şimdiden teşekkürler.
Hala benim için çalışmıyor. Verileri günlüğe kaydetmeyi denedim ama hiçbir değer elde edemiyorum. Onun scope.on işlevine bile girmiyor – anonymous5671
Sorunuzu, $ rootScope. $ Broadcast() 'olarak adlandırdığınız yere dahil etmek için günceller misiniz? Kodun biraz çalıştığından emin olmak için hata ayıkladı mı? – Lex
Yayınlanmış denetleyiciyi ekledim, bir göz atın – anonymous5671