यहाँ मेरी कोणीय कोड में एक सामान्य ES5 समारोह जो काम करता है:ES6 तीर कार्य कोणीय के साथ असंगत हैं?
app.run(function($templateCache){ $templateCache.put('/some','thing') });
मैं इसे ES6 तीर समारोह
app.run($templateCache => $templateCache.put('/some','thing'));
कन्वर्ट करने के लिए चाहता था, लेकिन यह त्रुटि
Uncaught Error: [$injector:unpr] Unknown provider: '/some'Provider <- '/some'
http://errors.angularjs.org/1.4.6/$injector/unpr?p0='%2Fsome'Provider%20%3C-%20'%2Fsome'
REGEX_STRING_REGEXP @ angular.js:68
(anonymous function) @ angular.js:4287
getService @ angular.js:4435
(anonymous function) @ angular.js:4292
getService @ angular.js:4435
invoke @ angular.js:4467
(anonymous function) @ angular.js:4297
forEach @ angular.js:336
createInjector @ angular.js:4297
doBootstrap @ angular.js:1657
bootstrap @ angular.js:1678
angularInit @ angular.js:1572
(anonymous function) @ angular.js:28821
trigger @ angular.js:3022
eventHandler @ angular.js:3296
हैं देता है ES6 तीर कार्य कोणीय के साथ असंगत है?
संपादित करें: मैंने सोचा था कि शायद कोणीय नाम $templateCache
लगा सकते और इसलिए यह इंजेक्षन करने में असमर्थ नहीं है लेकिन फिर मैं यह लॉग इन सांत्वना देने और यह इसे सही ढंग से प्रदर्शित करता है:
app.run($templateCache=>console.log($templateCache));
// =>
// Object {}
// destroy: function()
// get: function(key)
// info: function()
// put: function(key, value)
// remove: function(key)
// removeAll: function()
// __proto__: Object
आप समारोह के मापदंडों के नाम पर भरोसा नहीं करना चाहिए के लिए कोष्ठक की जरूरत है लगता है, क्योंकि यह होगा उस पल को काम करना बंद करें जब आप अपना कोड कम करते हैं। कुछ [एनजी-एनोटेट] (https://github.com/olov/ng-annotate) का उपयोग करें। –
एकमात्र अंतर यह प्रतीत होता है कि आपका फ़ंक्शन कुछ वापस कर देता है। और पाठ्यक्रम का वाक्यविन्यास। – Bergi