Open jmls opened 7 years ago
when building the template cache, it seems to me as if each template is wrapped into it's own function:
(function() { var module; try { // Get current templates module module = angular.module('myModule'); } catch (error) { // Or create a new one module = angular.module('myModule', []); } module.run(["$templateCache", function($templateCache) { $templateCache.put('myApp/components/form1.html', '<html here>'); }]); })(); (function() { var module; try { // Get current templates module module = angular.module('myModule'); } catch (error) { // Or create a new one module = angular.module('myModule', []); } module.run(["$templateCache", function($templateCache) { $templateCache.put('myApp/components/form2.html', '<html here>'); }]); })();
when using other tools, I got the following:
(function() { var module; try { // Get current templates module module = angular.module('myModule'); } catch (error) { // Or create a new one module = angular.module('myModule', []); } module.run(["$templateCache", function($templateCache) { $templateCache.put('myApp/components/form1.html', '<html here>'); $templateCache.put('myApp/components/form2.html', '<html here>'); }]); })();
which is obviously a lot more concise
Is there any reason for writing out the code this way ?
also, is it possible to supress the check for the module, and just use
module = angular.module('myModule');
The third point, and I am struggling to understand it, is that sometimes the cache does not seem to get the template:
(function() { var module; try { // Get current templates module module = angular.module('myModule'); console.log("#1") } catch (error) { // Or create a new one module = angular.module('myModule', []); console.log("#2") } console.log("#3") module.run(["$templateCache", function($templateCache) { console.log("#4") $templateCache.put('myApp/components/form1.html', '<html here>'); }]); })();
sometimes I see #1, #3 but not #4 - I've tried adding try catch blocks to no avaial - has anyone seen this sort of behaviour ?
when building the template cache, it seems to me as if each template is wrapped into it's own function:
when using other tools, I got the following:
which is obviously a lot more concise
Is there any reason for writing out the code this way ?
also, is it possible to supress the check for the module, and just use
The third point, and I am struggling to understand it, is that sometimes the cache does not seem to get the template:
sometimes I see #1, #3 but not #4 - I've tried adding try catch blocks to no avaial - has anyone seen this sort of behaviour ?