typescript Angular 2:找不到名称“encodeUri”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41290875/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Angular 2: Cannot find name 'encodeUri'
提问by Ole Spaarmann
I'm trying to use http.get
to call a remote URL. I append a search string to the base URL. This search string should be URL encoded. But I get this error:
我正在尝试使用http.get
来调用远程 URL。我将搜索字符串附加到基本 URL。此搜索字符串应该是 URL 编码的。但我收到此错误:
Cannot find name 'encodeUri'
找不到名称“encodeUri”
How should I import it or make it available? This is a standard Javascript function and I had the same problem trying to use the Javascript's Math
object.
我应该如何导入或使其可用?这是一个标准的 Javascript 函数,我在尝试使用 Javascript 的Math
对象时遇到了同样的问题。
search(term:string):any {
let encoded_term:string = encodeUri(term);
let url:string = [Config.API_BASE_URL, 'members', 'search', '?q=' + encoded_term].join('/');
return this.http.get(url)
.map(res => res.json())
.map(res => {
return this.buildPage(res);
});
}