2017-01-23 75 views
1

我收到「錯誤:權限被拒絕訪問屬性‘拒絕’」錯誤的垂釣者2.請參見下圖:錯誤:權限被拒絕訪問屬性「甩」在垂釣者2

火狐的屏幕截圖鉻的

enter image description here

截圖 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) }} 

回答

2
data?.qwqw 

使用問號將確保var不是未定義

+0

爲什麼'data'沒有得到嗎?我已經傳遞了'數據'可行。 –

+0

角度試圖在數據分配給變量之前呈現模板 – anshuVersatile

+0

謝謝,它正在工作。 –

相關問題