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