I wonder whether or not I should improve my current practice on creating/calling dialogs with AngularJS.
Think of a simple information, displayed on demand as a modal window. To create such a thing, I would write a directive, include it to my page and use ng-hide
to hide it.
If I want to call it, I would simply change the associated ng-hide value to false from within my main controller.
app.directive('modal',function(){
return{
restrict: 'E',
template: '<div ng-hide=state.modalVisibility></div>',
// etc
}
});
app.controller('Ctrl',function($scope){
$scope.state.modalVisibility = false;
$scope.changeVisibility = function(){
$scope.state.modalVisibility = true;
}
});
Are there any disadvantages or possible improvements on this practice? Is it a bad idea to have the modal-element "always there" but only displayed on demand?