Angular 无法读取属性';增补列表器';纯科尔多瓦项目(不含爱奥尼亚)中的空(点击)角8?

Angular 无法读取属性';增补列表器';纯科尔多瓦项目(不含爱奥尼亚)中的空(点击)角8?,angular,typescript,cordova,ionic-framework,Angular,Typescript,Cordova,Ionic Framework,在何处添加click EventListener?我无法读取null的属性“addEventListener” export class BookConfirmComponent implements OnInit { constructor() { document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() {

在何处添加click EventListener?我无法读取null的属性“addEventListener”

export class BookConfirmComponent implements OnInit {
    constructor() {
        document.addEventListener("deviceready", onDeviceReady, false);
        function onDeviceReady() {
            console.log(""device is ready");    //this works
            document.getElementById("myBtn").addEventListener("click", function() {
            console.log("button is clicked");     //Cannot read property 'addEventListener' of null
            });
        }
    }
}

欢迎来到SO。关联的html文件在哪里?
myBtn
的元素ID是否存在?app.component.html中是否存在ID为myBtn的元素。它只有这个按钮。