Jesper
Jesper

Reputation: 2814

Angular 2 npm start error

When i type 'npm start' in cmd, i get the following errors:

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.

Here's the bidding component:

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
}
}

}

Since the errors don't make any sense, my guess is that there is a problem with a parenthesis or bracket, but I've checked and can't find any. What have I done wrong? Thanks.

Upvotes: 0

Views: 55

Answers (1)

Pezetter
Pezetter

Reputation: 2862

As mentioned in the comments, angular 2 doesn't like var declarations within a class, line 16 and below.

Upvotes: 1

Related Questions