类型'Level'上不存在属性'dataLogs'

时间:2017-11-06 21:52:40

标签: angular

我是Angular 2中的新手,我正在尝试将TSMap属性设置为模型类,并且我收到以下错误:属性'dataLogs'在类型'Level'上不存在。

模型类是

import {DataLog} from "./datalog.model";
import {TSMap} from "typescript-map";
export class Level {
    dataLogs: TSMap<number, DataLog>;
    resultLevel: DataLog;
}

在组件类中,我声明了一个这样的变量:

dataLogs: TSMap<number, DataLog> = new TSMap<number, DataLog>();

我填充地图,然后点击按钮我试图将其分配给级别对象

this.levelOne.dataLogs = this.dataLogs;

我收到以下错误:

属性'dataLogs'在类型'Level'上不存在。

The component is the following:


import {Component, OnInit} from '@angular/core';
import {TSMap} from "typescript-map";

import {Level} from "../../models/level.model";
import {DataLog} from "../../models/datalog.model";

@Component({
    selector: 'game-screen',
    templateUrl: './ame-screen.component.html',
    styleUrls: ['./game-screen.component.css']
})
export class Game implements OnInit {
    game: Game;
    levels: Level[] = [];
    dataLogs: TSMap<number, DataLog>;
    levelOne: Level;

    constructor() {
        this.game = new Game();
        this.levelOne = new Level();
        this.dataLogs = new TSMap<number, DataLog>();
    }

    buttonA(){
        let dataLog = new DataLog();
        dataLog.hit = 1;
        this.dataLogsMap.set(this.numberOfClicks, dataLog);

        this.levelOne.dataLogs = this.dataLogs;
    } 
}

我做错了什么?

0 个答案:

没有答案