I keep getting this error when compiling my app. TS v2.0.3
app/components/profile.component.ts(13,12): error TS1005: '=' expected.
app/components/profile.component.ts(14,13): error TS1005: '=' expected.
app/components/profile.component.ts(16,10): error TS1005: '=' expected.
here's my code:
import { Component } from '@angular/core';
import { apiService } from '../services/api.service';
import 'rxjs/add/operator/map';
@Component({
moduleId: module.id,
selector: 'profile',
templateUrl: './profile.component.html'
})
export class ProfileComponent{
product[];
products[];
productTitle:string;
first[];
constructor(private _apiService:apiService){
this._apiService.getProduct().subscribe(product => {
//console.log(product.result.products);
this.product = product.result.products[0];
})
}
searchProd() {
this._apiService.updateTitle(this.productTitle);
this._apiService.getProduct().subscribe(productTitle => {
//console.log(productTitle.result.products);
this.first = productTitle.result.products[0];
this.products = productTitle.result.products;
})
}
}
I've read it could be because of updated syntax from TS and did updated it to latest 2.1.0 version and still got the error.
Anyone can help me on this?
Looks like you need a type specifier for those lines, something like:
product:any[];
products:any[];
first:any[];
If you have the more explicit types available, use those instead.
EDIT
As noted in comments on the question, using any can have its own issues. In that case, you will need to find the correct type of each of these variables and replace any with that. One possibility is product but without seeing more of the code it's difficult to tell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With