Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

309
Visualizações
How to prevent a component from starting/rendering when the required parameters are not filled correctly?

Say I have a component and I have bindings that are not optional, like so

angular.module("foo").component("fooComp", {
    bindings: {
      notOpt: "<",
    },
    templateUrl: "...",
    controllerAs: "...",
    controller: [fooCtrl],
  });
  function fooCtrl() {
    const $vm = this;

    $vm.$onInit = onInit;

    function onInit() {
      // ...
    }

  }

Is there a way that I can prevent the component from rendering without the help of a flag and ngIf? Something like a self destroy?

Thanks

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

What I ended up doing is just removing the element with $element.remove() and then also destroying the scope with $scope.destroy().

about 4 years ago · Juan Pablo Isaza Relatório

0

Try "Conditional render" :D I leave the site which tells you how to do it. React and Angular are both JavaScript. You can do what you need with this idea :D

https://www.digitalocean.com/community/tutorials/7-ways-to-implement-conditional-rendering-in-react-applications

If my answer helped you, pls select my answer :D

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda