【发布时间】:2017-03-18 09:33:36
【问题描述】:
运行我的应用时,我收到以下错误:
src/app/components/user.components.ts(33,11):错误 TS7006:参数“Hobbi”隐含地具有“任何”类型。 [0] src/app/components/user.components.ts(37,14): 错误 TS7006: 参数 'i' 隐式具有 'any' 类型。
这是我的代码:
@Component({
moduleId : module.id,
selector: 'user',
templateUrl: `user.components.html`,
})
export class UserComponent {
name : string;
email : String;
address: address;
hobbies : string[];
ShowHobbies : boolean;
constructor(){
this.name = 'Ratheesh';
this.email = 'babu.ratheesh@7nodes.com';
this.address={
street : 'Near Assisi Lane',
city: 'Ernakulam',
country : 'India'
}
this.hobbies = ['Reading', 'sports' , 'music']
this.ShowHobbies = false;
}
ToggleHobbies(){
// console.log('SHow');
if(this.ShowHobbies == true) {
this.ShowHobbies = false;
}else{
this.ShowHobbies = true;
}
}
addHobby(Hobbi){
this.hobbies.push(Hobbi);
}
deleteHobby(i){
this.hobbies.splice(i, 1);
}
}
interface address {
street : string;
city: string;
country :string;
}
【问题讨论】:
标签: angular