5
यहब्राउज़रइफ़ का उपयोग कर लूप में मुझे क्यों (...) की आवश्यकता नहीं है?
require('./AppCtrl');
काम करता है लेकिन यह मेरी अंतिम लक्ष्य के लिए त्रुटियों
_prelude.js:1 Uncaught Error: Cannot find module './AppCtrl's @ _prelude.js:1s @ _prelude.js:1(anonymous function) @ _prelude.js:1(anonymous function) @ index.js:48 @ index.js:3s @ _prelude.js:1(anonymous function) @ _prelude.js:11../config @ app.js:22s @ _prelude.js:1e @ _prelude.js:1(anonymous function) @ _prelude.js:1
angular.js:12416 Error: [ng:areq] Argument 'AppCtrl' is not a function, got undefined
http://errors.angularjs.org/1.4.5/ng/areq?p0=AppCtrl&p1=not%20a%20function%2C%20got%20undefined
at REGEX_STRING_REGEXP (angular.js:68)
at assertArg (angular.js:1795)
at assertArgFn (angular.js:1805)
at angular.js:9069
at setupControllers (angular.js:8133)
at nodeLinkFn (angular.js:8173)
at compositeLinkFn (angular.js:7637)
at publicLinkFn (angular.js:7512)
at angular.js:1660
at Scope.parent.$get.Scope.$eval (angular.js:15878)
में परिणाम है कि मैं इस स्यूडोकोड की तरह कुछ करने में सक्षम होना चाहते हैं, तो मैं
[ './AppCtrl' ].forEach(function(name) {
require(name);
});
करना
foreach name {
angular.module(...).controller(require(name));
}
लेकिन अभी मुझे यकीन नहीं है कि मुझे लूप के अंदर फ़ाइलों की आवश्यकता क्यों नहीं हो सकती है?
आप ऐसा करने की कोशिश क्यों कर रहे हैं? – Bergi
क्योंकि मुझे लगता है कि मैन्युअल रूप से प्रत्येक मॉड्यूल की आवश्यकता है, यह बहुत हास्यास्पद कोड है। – xenoterracide
हर जगह सबकुछ की आवश्यकता है कोड की गंध है, शायद आपके कोड में कुछ गड़बड़ है? हालांकि, आपको उन मॉड्यूल को गठबंधन करना चाहिए जिन्हें आप बड़े मॉड्यूल में हर जगह दोहराते हैं, और केवल हर जगह आयात करते हैं। एक सरणी और एक पाश का उपयोग नहीं करें। – Bergi