javascript - 错误 : Permission denied to access property "rejection" in angler 2

标签 javascript angular

我在 Angler 2 中收到“错误:访问属性“拒绝”的权限被拒绝”错误。请参见下图:

Firefox 截图

enter image description here

Chrome 屏幕截图 enter image description here

我在services.js 文件中添加了以下代码

getFooter(){
    return this.http.get(this.cons.footer)
      .map(response => response.json());
} 

我在组件文件中使用了以下代码

ngOnInit(){ 
this._pageService.getFooter()
.subscribe(
            data => this.data =  data.data, 
            error => console.log(error)
        ); 
}

我正在使用下面的 json 文件。

{
    "status": "success",
    "data": {
        "qwqw":"qqq",
        "footer_column_first": [
            "Alien Education",
            "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley. ",
            [
                [
                    "http://facebook.com",
                    "uploads/453085f6fb34252eeb15e26c381daf9b.jpg"
                ],
                [
                    "http://twitter.com",
                    "uploads/8c542d463e812318f71271a41850fd41.jpg"
                ],
                [
                    "http://linkedin.com",
                    "uploads/c29507573b1434ae96783c749248d958.jpg"
                ],
                [
                    "http://youtube.com",
                    "uploads/e311b879e07c9a6a8c924f758566e28f.jpg"
                ]
            ]
        ]
    }
}

我在模板 (.html) 中使用了打击代码。但我遇到了以下错误

{{ console.log(data.qwqw) }}

最佳答案

data?.qwqw

在变量中使用问号 它将确保 var 不是未定义的

关于javascript - 错误 : Permission denied to access property "rejection" in angler 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41804404/

相关文章:

c# - 构建长值数组的校验和

javascript - 如何在另一个函数中访问Object函数

javascript - 如何在没有 Jquery 的情况下将 HTML5 视频快照附加到滚动 DIV

angular - 在 Angular 4+ 中处理两个 URL(矩阵 && 查询)参数

javascript - ionic /Angular 传单指令 - 放大/缩小按钮不起作用

Javascript 类型错误 : Object Has No Method

javascript - 在组件中编辑动态 Promise

javascript - 错误类型错误 : Cannot set property 'paginator' of undefined

angular - Jasmine + Angular2 : This test module uses the component Login which is using a "templateUrl", 但它们从未被编译

php - 如何从MySQL获取图像并使用Angular 2显示