为了账号安全,请及时绑定邮箱和手机立即绑定

当用户在搜索栏中输入文本时显示列

当用户在搜索栏中输入文本时显示列

哆啦的时光机 2023-10-10 16:54:37
我正在做 Angular 项目,想知道当用户在搜索栏中输入任何文本时如何显示中间列。现在,我有用于用户输入的搜索栏和三个弹性列。当页面打开时,中间的列是隐藏的,但我希望当用户在搜索框中输入任何文本时它会显示。任何帮助将非常感激。.left {  flex: 2;}.right {  flex: 1;}.center{  flex: 1;  display: none;}.parent {  display: flex;  overflow: hidden;  width: 95vw;  margin-left: 30px;}<!-- Middle Column --!>    <div class="center">        <div class="chart-header">Charts</div>          <div>Chart will display here</div>    </div>      <!-- My user input/ search bar --!>  <input  [formControl]="inputCtrl" matInput class="input">
查看完整描述

2 回答

?
开心每一天1111

TA贡献1836条经验 获得超13个赞

// .html file      

 <div class="center" *ngIf="showColumn">

            <div class="chart-header">Charts</div>  

            <div>Chart will display here</div>

        </div>



   //.ts file

   showColumn = false;

     this.form.get('inputCtrl').valueChanges.subscribe(() => {

    this.showColumn = true;

  });


查看完整回答
反对 回复 2023-10-10
?
呼如林

TA贡献1798条经验 获得超3个赞

您可以订阅表单控制器的 valueChanges 事件


TS文件


this.form.get("inputCtrl").valueChanges.subscribe(selectedValue => {

  this.displayStyle = 'block';

})

HTML 文件


<div class="center" [ngStyle]="{'display':displayStyle}>

    <div class="chart-header">Charts</div>  

    <div>Chart will display here</div>

</div>


查看完整回答
反对 回复 2023-10-10
  • 2 回答
  • 0 关注
  • 54 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信