angular - 仅在首次登录时隐藏文本
问题描述
我的网站上有 3 页。
第一页-> 包含 3 个字段(姓名、电话号码、电子邮件)
用户输入信息
然后,第二页包含 3 个字段(地址、邮政编码、城市)
有一个标题“第一次连接”,如果用户在网站上连接了几次,我想隐藏这个标题。所以,我们会有这个:
最后一页
我该如何解决这个问题?我必须使用Route Guards
?
https://juristr.com/blog/2018/11/better-route-guard-redirects
第二页对我来说是个问题...
<!-- Second page : Start -->
<div class="container" *ngIf="addressComplete">
<div class="title" style="color: blue; font-size: 25px; text-align:center;"> First connection</div>
<div class="one">
<input type="text"
class="input"
placeholder="Address">
</div>
<div class="two">
<input type="text"
class="input"
placeholder="Zip Code">
</div>
<div class="three">
<input type="text"
class="input"
placeholder="City / State">
</div>
<div class="four">
<button class="submit" (click)="addressSubmit()">Submit</button>
</div>
</div>
<!-- Second page : End -->
我怎么能在我的 component.ts 中隐藏这个标题?
import { Component, OnInit } from '@angular/core';
import { UserInfo } from '../user-info';
@Component({
selector: 'app-sign-up',
templateUrl: './sign-up.component.html',
styleUrls: ['./sign-up.component.css']
})
export class SignUpComponent implements OnInit {
personalInfoComplete = true;
addressComplete = false;
creditCardComplete = false;
completedOrder = false;
stepOne = false;
stepTwo = false;
stepThree = false;
customer = false;
customerInformation = [];
fruite = ['apple', 'orange'];
userInfoArray: UserInfo;
name;
constructor() {}
ngOnInit() {
console.log('Fruite' + this.fruite.push('banana'));
console.log(this.fruite);
}
personalInfoSubmit() {
this.personalInfoComplete = false;
this.addressComplete = true;
this.stepOne = true;
this.customer = true;
console.log('Your Info ' + this.name.userInfoArray);
}
addressSubmit() {
this.addressComplete = false;
this.creditCardComplete = true;
this.stepTwo = true;
}
creditCardSubmit() {
this.creditCardComplete = false;
this.completedOrder = true;
this.stepThree = true;
}
}
如果你有兴趣这里是我的代码Stackblitz
解决方案
我不确定您所说的“连接到网站”究竟是什么意思,但我认为您必须在您的网站上放置一个 cookie 以跟踪特定用户是否已经访问过您的网站。然后你可以使用一个简单的布尔值来隐藏或显示标题。
作为站点节点,您可以通过使用角度形式大幅改进代码。它非常简单,并且具有强大的验证功能,可以为您节省大量代码。希望我能帮助你。
推荐阅读
- elixir - Elixir / Phoenix:为什么路由助手需要@conn?
- python - 如何抑制pyinstaller生成的可执行文件窗口中的所有警告
- linq - LINQ 识别连续出现中第一个满足条件的行
- postgresql - PSQL 套接字超时:连接超时错误
- arrays - 我正在学习打字稿为什么定义的数组在这里显示错误?
- zabbix - 如何知道 Zabbix Dashboard 调用的 API?
- sql-server - 如何将对象中的数值转换为要在电子邮件任务中发送的字符串?
- java - JAVA中HttpClient请求的编码类型
- command-line-interface - 错误请求 400 - Freeswitch CLI Oiriginate 连接两个客户端
- angular - browser.driver.wait 与 browser.wait