2017-08-01 66 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