Pull out view's data from a list into modal



I have an ion-view where a there is a list of element:


When I touch and hold one of the element, I want my modal gets the element information (ex: apple)

Is it possible to do that with a modal? If so, how can I do it?

My code in the controller looks like this and don’t know where I could push “fruit” into the modal

vm.onHold = function(fruit) {
      // do something
      console.log("hold " + fruit.name);

// Create and load the Modal
$ionicModal.fromTemplateUrl('views/editFruitName.html', {
        scope: $scope,
        animation: 'slide-in-up'
}).then(function(modal) {
        $scope.editFruitNameModal = modal;

// Called when the form is submitted
$scope.editFruitName = function(fruit) {
      console.log("edit fruit");


    // Save new fruit name

// Close the edit fruit modal
$scope.closeEditFruitName = function() {

Hope that I was clear

Thanks in advance!


I think I found how to do it by myself!

I just added a new scope assigned to the model that I passed into my vm.onHold function

vm.onHold = function(fruit) {
    $scope.fruit = fruit;

And in the modal view, just did {{ fruit.name }} and it worked.

If you know a more elegant way, please let me know! :smile: