I am having trouble opening a modal on body load. Here is my code, that I pretty much copied and pasted from here:
.controller('LoginController', function($scope, $ionicModal) {
$ionicModal.fromTemplateUrl('templates/login.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
});
$scope.openModal = function() {
$scope.modal.show();
};
$scope.closeModal = function() {
$scope.modal.hide();
};
//Cleanup the modal when we're done with it!
$scope.$on('$destroy', function() {
$scope.modal.remove();
});
// Execute action on hide modal
$scope.$on('modal.hidden', function() {
// Execute action
});
// Execute action on remove modal
$scope.$on('modal.removed', function() {
// Execute action
});
});
…
<script id="templates/login.html" type="text/ng-template">
<ion-modal-view>
<ion-header-bar class="bar-dark">
<h1 class="title">Login to remind.cc</h1>
</ion-header-bar>
<ion-content>
Hello!
</ion-content>
</ion-modal-view>
</script>
I am able to open the modal using "ng-click=“openModal()” but I want to instead open it using body onLoad. However, this is not working for me. Yet it works in this example, and I cannot for the life of me figure out why.
Any help would be greatly appreciated.