Manage $ionicModal within a Controller: undefined error

Maybe this is a very newbie question, but I’m facing troubles and I hope in your help.

So, I have a Controller which instantiates a Modal. The View has a button. When clicked, the button should call a controller function that performs some instructions and then opens the modal.

I thought it would be simple, this is my code:

// Load the modal from the given template URL
$ionicModal.fromTemplateUrl('modalRows.html', function($ionicModal) {
        $scope.modalRows = $ionicModal;
    }, {
        // Use our scope for the scope of the modal to keep it simple
        scope: $scope,
        // The animation we want to use for the modal entrance
        animation: 'slide-in-up'
});

$scope.loadRows = function(i) {
    $scope.data.rowsContent = $scope.orders[index];
    $scope.modalRows.show();
};

But when I call the loadRows() function I get undefined: $scope.modalRows doesn’t exist…

What am I doing wrong?

Thanks