【发布时间】:2018-01-08 00:49:10
【问题描述】:
我创建了一个服务并尝试传递一个参数。当我尝试使用参数定义它时,我得到一个编译错误。
这很好用
createMovieCat(){
/* var headers = new Headers({"Access-Control-Request-Method" : "POST" , "Content-Type": "application/json" });
const options = new RequestOptions( {headers: headers});
*/
this._createURL = "http://localhost:8080/AdaRVM/api/movieCategory/create";
this.emv = new EmovieCat();
this._http.post(this._createURL,JSON.stringify(this.emv)).subscribe(response =>{
console.log(response.json());
});
}
当我向函数添加参数时,我得到标题中提到的编译错误。看起来很简单,但我看不出有什么问题,任何帮助都会得到帮助。谢谢。
createMovieCat(emv:EmovieCat){
/* var headers = new Headers({"Access-Control-Request-Method" : "POST" , "Content-Type": "application/json" });
const options = new RequestOptions( {headers: headers});
*/
this._createURL = "http://localhost:8080/AdaRVM/api/movieCategory/create";
// this.emv = new EmovieCat(); I removed this line
this._http.post(this._createURL,JSON.stringify(emv)).subscribe(response =>{
console.log(response.json());
});
}
我的模特。
export class EmovieCat{
id:String = "test";
rev:String;
dataModelVersion:number = 99;
}
【问题讨论】:
-
您是否在代码中的任何地方使用该方法?因为错误表明您试图在不提供所有参数的情况下调用函数。
-
你在函数调用中添加了这个参数吗?
-
嗯,我在一个旧文件中有一个没有参数的调用,但编辑器没有警告我,谢谢。
标签: angular