Inside my ng-view
, I have included different views using ng-include
.
I'm using ng-if
to show or hide any view based on the URL parameters.
Inside my ng-view
<div>
header
</div>
<ng-include src="'../views/about.html'" ng-if="obj.var1"></ng-include>
<ng-include src="'../views/contact.html'" ng-if="obj.var2"></ng-include>
<div>
footer
</div>
Inside my controller
app.controller('myCtrl', ['$scope', '$location', function($scope, $location){
if($location.search().hasOwnProperty('about')){
$scope.obj.var1 = true;
}
}])
The problem is occuring when my page is not connected to the internet. I'm getting an internet disconnected error and my HTML inside the ng-include
is not getting loaded.
I would like to know how to catch this error, so that I can print out an appropriate message on the screen. I have tried a simple try and catch, but it didn't seem to work.