How to work with Angular ngIF with screen resolution?

Asked

Viewed 1,115 times

1

See below how the web page looks;

inserir a descrição da imagem aqui

Now look at the screen with resolution below 992px

inserir a descrição da imagem aqui

This happens because of the css column

I would like to remove this column when it reaches less than 992px with ngIF of the angular, is it possible ? If possible as I should?

This one is code?

<div class="container">
    <div class="ui-g">
        <div class="ui-g-12  ui-lg-3"></div>
        <div class="ui-g-12  ui-lg-3 conheca_projeto"><h1><p>CONHEÇA</p>  O PRJETO</h1></div>
        <div class="ui-g-2  ui-lg-2">
            <div class="seta_topo animated  fadeInDown">
                <img src="assets/img/seta.JPG" height="250" >
            </div>
        </div>
        <div class="ui-g-12  ui-lg-4  seja_doador">
                <h1>SEJA UM DOADOR</h1>
            </div>
        <div class="ui-g-12  ui-lg-3"></div>
    </div>
</div>
  • What if it was hidden using Media Queries with CSS?

  • 1

    Performing this implementation will only disappear from the screen, but will not take the component and ngIF act on top of the component.

2 answers

2


Catching width onInit

public innerWidth: any;
ngOnInit() {
    this.innerWidth = window.innerWidth;
}

To keep updated on resize.

@HostListener('window:resize', ['$event'])
onResize(event) {
  this.innerWidth = window.innerWidth;
}

Html

<div *ngIf="innerWidth > algumNumero">
  • I just saw your post now, I’m still going to test it, but I can’t understand that this suggestion works because there is no fixation of the resolution size for it to be executed, but as I said before, I haven’t tested it yet.

  • It worked man, you’re beast hahaha, thank you very much

1

You could remove the component using media queries.

If it suits you, you can do it this way:

 @media screen and (max-width: 992px) {
   .conheca_projeto{  display: none ; } 
 }
  • I was unsuccessful with that suggestion :(

  • specifically what was the problem?

  • I would like the acoluna that is the arrow image was removed when it reached 992 px, if not understand I explain again without problem.

  • 1

    Yes, I get it. Theoretically this media wanted me to pass would solve it. You can apply it and take a look at inspecting element if her display turned out to be None?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.