How to implement an alert in the corner HTML page?

0

As you can see in the figure below the component Angular is composed of component, css and HTMl

mediafile-cadastrar.component.htmlItriedtoputasimpleimplementationofalertasyoucanseebelow;

<scripttype="text/javascript">
  alert("alo tudo bem?");
  </script>

Being that it did not catch, but if I put in the index.html file that is in the root of the project it catches perfectly.

I want to be able to implement the alert in the page media-cadastrar.component.html file, how could I do this?

    
asked by anonymous 05.04.2018 / 15:11

2 answers

1

>

  

HTML

<button (click)="botaoClicado()">Clique</button>
  

JS - You create a method to trigger the alert on the click of the button

export class midiaCadastrarComponent implements OnInit {
    botaoClicado() {
       alert('Botão clicado!');
    }
}
    
05.04.2018 / 15:59
0

In the media-cadastrar.component.html file try to do this ..

<!DOCTYPE html>
<html>
<body>

<input type="button" value="Button" onclick="alerta()"/>

<script>
function alerta(){
	alert("alo tudo bem?");
}
</script>

</body>
</html> 
    
05.04.2018 / 16:06