Angular 2 npm启动错误

时间:2016-12-21 22:53:08

标签: angular typescript

当我输入'npm start'在cmd中,我收到以下错误:

app/bidding.component.ts(16,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
app/bidding.component.ts(23,22): error TS1005: ',' expected.
app/bidding.component.ts(23,36): error TS1005: ',' expected.
app/bidding.component.ts(23,54): error TS1005: ';' expected.
app/bidding.component.ts(38,15): error TS1005: ';' expected.
app/bidding.component.ts(40,9): error TS1005: ':' expected.
app/bidding.component.ts(43,43): error TS1005: ',' expected.
app/bidding.component.ts(44,6): error TS1005: ',' expected.
app/bidding.component.ts(46,9): error TS1005: ':' expected.
app/bidding.component.ts(46,47): error TS1005: ',' expected.
app/bidding.component.ts(49,15): error TS1005: ';' expected.
app/bidding.component.ts(50,14): error TS1005: ',' expected.
app/bidding.component.ts(50,20): error TS1005: ',' expected.
app/bidding.component.ts(50,29): error TS1005: '=' expected.
app/bidding.component.ts(70,1): error TS1128: Declaration or statement expected.

以下是出价组件:

import { BiddingService, Bid  } from './bidding.service';
import { Component } from '@angular/core';
import * as Rx from 'rxjs/Rx';

@Component({
moduleId: module.id,
selector: 'my-bidding',
templateUrl: 'bidding.component.html'
})

export class BiddingComponent {  


bidList = "No bids submitted yet";
highestBid = "0";
var popUpContainerDisplay = document.getElementById('popUpContainer');
var popUpAcceptContainerDisplay = document.getElementById('acceptPopUp');
var popUpDeclineContainerDisplay = document.getElementById('declinePopUp');
var popUpWarningContainerDisplay = document.getElementById('warningPopUp');
arrayReset = false;


constructor(private biddingService: BiddingService) {
    biddingService.bids.subscribe(bid => {      

        this.bidList = bid.bidderArrayText.join('');
        this.highestBid = bid.bidLabelMessage;
        this.popUpContainerDisplay.style.display = bid.popUpContainerDisplay;
        this.popUpContainerDisplay.style.opacity = bid.popUpContainerOpacity;                        
        this.popUpAcceptContainerDisplay = bid.popUpAcceptContainerDisplay;
        this.popUpDeclineContainerDisplay = bid.popUpDeclineContainerDisplay;
        this.popUpWarningContainerDisplay = bid.popUpWarningContainerDisplay;
        this.arrayReset = bid.arrayReset; 

    });
}

sendToServer(): void{

var msgToServer = {
    bid: document.getElementById('bidTextbox').value,
    bidder: document.getElementById('bidderTextbox').value,
    resetArrayBoolean: this.arrayReset;   
};

this.biddingService.bids.next(msgToServer);
}

popUpFadeOut(): void{
if(container.style.opacity == 0){
    container.style.opacity = 1;
    container.style.display = "block";

    var fading = function fade() {
        if ((container.style.opacity -= .01) <= 0)
        {
            container.style.dispaly = "none";
            container.style.opacity = 0;
        }
        else
        {
            requestAnimationFrame(fade);
        }
    }

    setTimeout(fading, 1000); //popup box fades away after 1 seconds
}
}

}

由于错误没有任何意义,我的猜测是括号或括号出现问题,但我已经检查过,无法找到。我做错了什么?谢谢。

1 个答案:

答案 0 :(得分:1)

如评论中所述,angular 2不喜欢类16行及以下的 var 声明。