2017-08-01 67 views
0

我有一個簡單的應用程序,我得到這個錯誤。不能獲取 /。並在控制檯中。 Error in event handler for (unknown): TypeError: Cannot read property 'checked' of null at Object.SL_BBL_locer (chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/content/js/inject/translator.js:1174:41) at chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/content/js/inject/data.js:100:30錯誤我角。不能GET/

我真的不知道,我做錯了什麼。這是我的代碼。

app.module

import { BrowserModule } from '@angular/platform-browser'; 
import { NgModule } from '@angular/core'; 
import { AppComponent } from './app.component'; 
import { DashboardComponent } from './dashboard/dashboard.component'; 
import {AppRoutingModule} from './app-routing.module'; 

@NgModule({ 
    declarations: [ 
    AppComponent, 
     DashboardComponent 
    ], 
    imports: [ 
    BrowserModule  
    ], 
    providers: [], 
    bootstrap: [AppComponent] 
}) 
export class AppModule { } 

app.component

import { Component } from '@angular/core'; 

    @Component({ 
     selector: 'app-root', 
     templateUrl: './app.component.html', 
     styleUrls: ['./app.component.css'] 
    }) 
    export class AppComponent { 
     title = 'app'; 
    } 
**app.component.html** 

<div> 
<app-dashboard></app-dashboard> 
</div> 

dashboard.component

import { Component, OnInit } from '@angular/core'; 

@Component({ 
    selector: 'app-dashboard', 
    templateUrl: './dashboard.component.html', 
    styleUrls: ['./dashboard.component.css'] 
}) 
export class DashboardComponent implements OnInit { 

    constructor() { } 

    ngOnInit() { 
    } 

} 

dashoboard.component.html

<div> Im here</div> 
+0

你的錯誤信息是說你想讀一個變量爲空,而不是一個對象「選中」屬性。但是你提供的代碼似乎與錯誤有關。 –

+1

這條線是幹什麼的:'this.workSchedules = WorkSchedules;'?它似乎是將一個類型分配給一個數組? – DeborahK

+0

@CodeSpirit那這個問題我無法找到我的代碼的任何地方我有檢查 – user3701188

回答

0

我假定你workschedule.module是一個功能模塊。在這種情況下,你需要將CommonModule添加到@NgModule的進口性質:

@NgModule({ 
     imports: [ 
     CommonModule, 
     WorkScheduleRoutingModule 
     ], 
     declarations: [ 
     WorkscheduleComponent 
     ], 
     providers: [] 
    }) 
+0

是的,我在workchedule.module中導入了WorkScheduleRoutingModule,所以我在app.module中導入了這個模塊,我想這就是我所要做的 – user3701188