Currently, I am attempting to determine if a folder exists so that I can make decisions on which files to include using ng-include
.
This is what I have so far:
$scope.isVisible = {
buttons: checkForClientOverwride('buttons'),
itemList: checkForClientOverwride('itemList'),
// ... more variables
onLoad: checkForClientOverwride('onLoad'),
configurationManager: checkForClientOverwride('configurationManager')
};
function checkForClientOverwride(fn){
var result = {
url: 'app/modules/functions/' + fn + '/' + fn + '.html'
},
clientPath = 'app/modules/client code/' + fn + '/' + fn + '.html';
if(view.viewFunctions[fn] === undefined){
return false;
}
$http.get(clientPath)
.then(function(response){
console.info('response : ', clientPath, response);
result.url = clientPath;
})
.catch(function(error){
console.info('error : ', clientPath, error);
})
.finally(function(){
console.info('result : ', result);
return result;
$scope.isVisible[fn] = result;
});
};
Here is how the view is set up:
<div ng-if="isVisible.itemList" ng-include="'app/modules/functions/itemList/itemList.html'"></div>
<div ng-if="isVisible.inputFields" ng-include="'app/modules/functions/inputFields/inputFields.html'"></div>
<div ng-if="isVisible.configurationManager" ng-include="{{ isVisible.configurationManager.url }}"></div>
<div ng-if="isVisible.calculate" ng-include="'app/modules/functions/calculations/calculations.html'"></div>
This is my tree structure:
+ app
+--+ modules
| +--+ functions
| | +--+ buttons
| | | +--- buttons.html
| | +--+ itemList
| | | +--- itemList.html
| | +--+ onLoad
| | | +--- onLoad.html
| | +--+ configurationManager
| | | +--- configurationManager.html
| +--+ client code
| | +--+ configurationManager
| | | +--- configurationManager.html
+--- core.js
+--- route.js
+ index.html
The current code checks if a file exists, but I am looking for a way to check if a folder exists. Also, is there a method to load this synchronously?
EDIT
When attempting to utilize $http.get
on the folder app/modules/client code
, I encounter the following error in my console.log
:
config: Object
data: "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ↵<html xmlns="http://www.w3.org/1999/xhtml"&...