angular - Angular 6 - 触发浏览器“保存登录提示”
问题描述
所以,我已经创建了小型应用程序(学习目的)来管理一些数据。问题是,浏览器没有提示在登录页面上保存登录帐户,因为所有应用程序都是single page app
并且我希望我的浏览器提示保存登录帐户。我已经找到了一个可能适合我的答案,但因为我只是学习这个角度 6,我无法真正将它们联系起来。所以这是我的代码。
登录组件.ts
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
loginForm : FormGroup;
username = "";
password = "";
constructor(
public global: GlobalService,
public messagerService: MessagerService,
private cookie: CookieService, //persistent
private router: Router,
private fb: FormBuilder
) {
this.loginForm = fb.group({
username: ["asdsa", Validators.required],
password: ["adssa", Validators.required]
});
}
login(){
var helper = new JwtHelperService();
if(this.username=='' || this.password=='')
this.messagerService.alert({
title: 'Error',
icon: 'error',
msg: 'Please fill the forms!'
});
else{
this.global.login(this.username, this.password).subscribe(
data => {
if(data.success=='1'){
this.cookie.set('jwtObj', data.jwt, new Date().getSeconds() + 7200, '/');
this.global.loginCheck();
}
else if(data.success == '0'){
this.messagerService.alert({
title: 'Error',
icon: 'error',
msg: data.msg
});
}
},
);
}
}
ngOnInit() {
}
submitForm(value){
console.log(value);
}
}
login.component.html
<eui-panel [title]="'Login Panel'" [collapsible]="true" [bodyStyle]="{padding:'20px'}" style="height:320px;width:400px; margin:auto;margin-top: 25vh">
<h2>RUC SSO LOGIN</h2>
<form novalidate #formm [formGroup]="loginForm" (ngSubmit)="submitForm(loginForm)">
<div style="margin-bottom:10px;">
<label [for]="t1" align="top">Username:</label>
<eui-textbox #t1 formControlName="username" iconCls="icon-man" placeholder="username" style="width:100%"></eui-textbox>
</div>
<div style="margin-bottom:10px;">
<label [for]="t2" align="top">Password:</label>
<eui-passwordbox #t2 formControlName="password" placeholder="password" style="width:100%"></eui-passwordbox>
</div>
<div>
<eui-linkbutton (click)="submitForm(loginForm)">Login</eui-linkbutton>
</div>
</form>
</eui-panel>
如何触发浏览器提示?
解决方案
好的,我创建了一个简单的示例,在 Firefox stackblitz app URL上进行了测试
编辑:您正在使用easyui,这可能是easyui的问题,但在表单提交和导航到其他组件时保存密码提示。
推荐阅读
- python - 有没有办法根据两个条件删除python中的重复项?
- python - 使用kmeans python进行集群和分区的字典
- python-3.x - Python3将字节对象转换为文件对象
- keras - Keras回调执行顺序?
- python - 为什么 Marshmallow 对多个项目返回空但返回单个项目?
- angular - Angular 8:使用 ngRx/store 从 reducer 获取的结果不会以异步方式更新 UI(html)
- cefsharp - 无法在 CefSharp 应用程序中设置表单输入变量
- ios - 适用于 iOS 的 glib 构建
- c# - JSON反序列化后处理空值
- javascript - 如何为 React 应用程序中的不同组件设置不同的背景颜色?