Parsing error on class variable declaration


#1

Hi there,

I’ve some troubles with class variables declarations.

Indeed, compiler always returns me Unexpected token (12:10) while parsing file: /my/file/path/.

The error is based on first variable declaration firstForm: ControlGroup.

Could you help me please?

Here my code :

import {Page, NavController, NavParams} from 'ionic-angular';
import {Component} from 'angular2/core';
import {FORM_DIRECTIVES, FormBuilder,  ControlGroup, Validators, AbstractControl} from 'angular2/common';
import {SecondPage} from '../second/second';

@Page({
  templateUrl: 'build/pages/diagnostic/first/first.html',
  directives: [FORM_DIRECTIVES]
})
export class FirstPage {

	firstForm: ControlGroup;
    firstName: AbstractControl;
    lastName: AbstractControl;

	static get parameters() {
		return [[NavController], [NavParams]];
	}

	constructor(nav, navParams, fb: FormBuilder) {
		this.nav = nav;
        this.firstForm = fb.group({  
            'firstName': ['', Validators.compose([Validators.required, Validators.minLength(2)])],
            'lastName': ['', Validators.compose([Validators.required, Validators.minLength(2)])]
        });

        this.firstName = this.firstForm.controls['firstName'];
        this.lastName = this.firstForm.controls['lastName'];
	}

	onSubmit(value: string) : void {
		if (this.firstForm.valid) {
			console.log('Submitted value = ' + value);
		}
	}
}

#2

This looks like some unholy frankenmix of TypeScript and JavaScript-flavored angular code. What language are you trying to use?


#3

Hi,

Thanks for your answer.
Indeedn I tried to use TypeScript with JavaScript, problem solved with passing my project in TypeScript.

Thank you