मैं एक tutorial में इस उदाहरण कोड पाया याद आ रही है:Angular2 http .map समारोह
getRandomQuote() {
this.http.get('http://localhost:3001/api/random-quote')
.map(res => res.text())
.subscribe(
data => this.randomQuote = data,
err => this.logError(err),
() => console.log('Random Quote Complete')
);
}
लेकिन जब इसका इस्तेमाल करने की कोशिश कर रहा, मैं केवल TypeError: this.http.get(...).map is not a function in [null]
मिलती है:
getChannels():Promise<Channel> {
return this.http.get('...')
.map(function (response:Response) {
...
}).toPromise();
}
मेरे टाइपप्रति संकलक मुझसे कहता है कि वे विधियां उपलब्ध हैं लेकिन http.get()
के वापसी मूल्य का निरीक्षण करते समय वे गायब हैं।
मैं वर्तमान angualar2 शुरुआती गाइड के package.json प्रयोग किया है:
"dependencies": {
"angular2": "2.0.0-beta.0",
"systemjs": "0.19.6",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"zone.js": "0.5.10"
},
...
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/http.dev.js"></script>
कोई भी विचार मैं इस बिंदु पर गलत क्या मिल सकता है
?
शायद http://stackoverflow.com/questions/34394708/in-angular-2-0-0 -बेटा -0-मैप-एंड-फ़िल्टर-गायब-से-फॉर्म-इनपुट-ऑब्जेर या http://stackoverflow.com/questions/34394708/in-angular-2-0-0-beta-0 -map और फिल्टर-रहे-लापता-से-एक फार्म आदानों-obser/34396552? –
इसे हजारों बार उत्तर दिया गया है, इसे केवल एक खोज की आवश्यकता है। –