one small issue i have, how to make this code to work:
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormControl,FormBuilder, Validators } from '@angular/forms';
import { Http, Response, Headers } from '@angular/http';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { map,share } from 'rxjs/operators';
import {DataService} from '../data.service';
@Component({
selector: 'app-change-room',
templateUrl: './change-room.component.html',
styleUrls: ['./change-room.component.css'],
})
export class ChangeRoomComponent implements OnInit {
data: Array[Object];//error
registerForm: FormGroup;
http: Http;
router: Router;
postResponse: String;
constructor(builder: FormBuilder, http: Http, router: Router, private dataService: DataService,route: ActivatedRoute) {
this.data = this.dataService.getData();
console.log(this.data[0].roomname, this.data.tv);
this.http = http;
this.router = router;
this.registerForm = builder.group({
roomName: [""+this.data[0].roomname],
hasTV: [""+this.data[0].tv],
beds: [""+this.data[0].beds]
});
}
ngOnInit() {
}
onModifyRoom(): void {
var data1 = "roomName="+this.registerForm.value.roomName+"&hasTV="+this.registerForm.value.hasTV+"&beds="+this.registerForm.value.beds+"&brojkvadrata="+this.registerForm.value.brojkvadrata;
var headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
this.http.post('http://localhost/it255/updateroom.php', data1, {headers: headers}).subscribe((result) => {
this.router.navigateByUrl('rooms');
alert("Succesfully changed room")
}, (error) => {
this.router.navigateByUrl('aboutus');
});
}
}
i get errors like this : Generic type 'Array' requires 1 type argument(s). Generic type 'Array' requires 1 type argument(s).
What should i do to make this to work in angular 6, this worked when i triy in angular 2.