0
我最近發現並開始在JHipster中開發。如何自動關閉JHipster的提醒?
我面臨的第一個障礙之一是自動關閉警報。到目前爲止,我已經瞭解到,JHipster使用Bootstrap UI alerts,所以我想,當用戶試圖登錄(綠色的),以適應在sample project of JHipster捆綁警報,這是在主頁顯示:
HTML代碼如下:
<div ng-switch="vm.isAuthenticated()">
<div class="alert alert-success" ng-switch-when="true" data-translate="home.logged.message" translate-values="{username: '{{vm.account.login}}'}">
You are logged in as user "{{vm.account.login}}".
</div>
</div>
其中我修改像這樣:
<div class="alert alert-success" ng-switch-when="true" data-translate="home.logged.message" translate-values="{username: '{{vm.account.login}}'}" close="closeAlert()" ng-if="show" dismiss-on-timeout="3000" >
You are logged in as user "{{vm.account.login}}".
</div>
Javascri PT文件home.controller.js看起來是這樣的:
(function() {
'use strict';
angular
.module('pruebablogApp')
.controller('HomeController', HomeController);
HomeController.$inject = ['$scope', 'Principal', 'LoginService', '$state', 'AlertService'];
function HomeController ($scope, Principal, LoginService, $state, AlertService) {
var vm = this;
vm.account = null;
vm.isAuthenticated = null;
vm.login = LoginService.open;
vm.register = register;
$scope.$on('authenticationSuccess', function() {
getAccount();
});
getAccount();
function getAccount() {
Principal.identity().then(function(account, $scope) {
vm.account = account;
vm.isAuthenticated = Principal.isAuthenticated;
if (vm.isAuthenticated){
$scope.show = true;
}
});
}
function register() {
$state.go('register');
}
function closeAlert() {
$scope.show = false;
}
}
})();
此方法不適合我的工作。我嘗試了其他方法,例如this one或this one(它應該適用於按鈕點擊)。
我在做什麼錯?
感謝您的回答。我只是嘗試這樣做: _controller:_ 'AlertService.warning( 「你好,我是一個警報。」);' _View:_ ' ' 我得到這個從要素Chrome Debug中的檢查器: ' ' 尚未顯示警報。有些東西還是錯的。 –
wickedchild
嘗試一口吞乾淨的構建。如果您正在編輯示例應用的其他實體,例如標籤或BankAccount,您是否收到警報?例如,當您創建或編輯實體時,您應該會收到一條信息警報。 – duderoot
的確,我收到了這些提醒。試圖重建整個項目,沒有任何改善。試圖立即使用AngularJS警報。謝謝您的幫助! – wickedchild