How do you use document.getElementById to get a modal element? I'm trying to manually show and hide a modal via code in my home component typescript file.
I already have a working modal that works when a button is pressed - now I want to manually toggle the modal when certain conditions occur in code.
var errorModalBox = document.getElementById("errorModal");
Property 'modal' does not exist on type 'HTMLElement'.
Since you are using Typescript with Angular 2, the typescript compiler will throw an error when you reference the jQuery object using "$" or "jQuery". To fix the compile error, add this statement below the last import statement in your Home Component.
declare var $:any;
Then just change your code from:
var errorModalBox = document.getElementById("errorModal"); errorModalBox.modal('show');