Is there a best-practice for falling back on ngInclude
?
The initial solution I came up with was for the controller (or parent directive, where applicable) to have something along the lines of
scope.someInclude = 'views/x/custom/'+someVar+'.html';
scope.$on('$includeContentError', function(event, failedTemplate){
if(scope.someInclude === failedTemplate){
scope.someInclude = 'views/x/default.html';
}
});
Where the template would simply ng-include='someInclude'
.
This doesn't seem like a great solution for several reasons. Among the largest of which being that it won't remember which templates don't work, along with the extra boilerplate.
Before I go building a service to alleviate some of these things, are there any simpler solutions that I'm missing?