Simple way to pass in data or get result of modal?

I have a group of buttons when one is clicked I want to allow the user to select an option and run a command.

I have the button and modal working, but i cant figure out how to use the user’s choice.

Anyone know a simple way of getting the result of a modal dialog?

<script type="text/ng-template" id="myModalContent.html">
  <div class="container popup">
    <button type="button" class="btn btn-lg btn-block"
      ng-click="$close('Selecttion1')">
      Selection 1
    </button>
        <button type="button" class="btn btn-lg btn-block"
      ng-click="$close('Selecttion2')">
      Selection 1
    </button>
  </div>
</script>
<button type="button" class="btn btn-lg btn-block"
        ng-click="aVar = openModal('myModalContent.html', false, 'sm')">
  Result is {{aVar}}
</button>

Unfortunately that’s not possible without using a Javascript controller.

However you can do something like this, it’s not a by-the-book solution but it will work:

<script type="text/ng-template" id="myModalContent.html">
  <div class="container popup">
    <button type="button" class="btn btn-lg btn-block"
      ng-click="sendCmd('Item', 'Command1'); $close()">
      Selection 1
    </button>
        <button type="button" class="btn btn-lg btn-block"
      ng-click="sendCmd('Item', 'Command2'); $close()">
      Selection 2
    </button>
  </div>
</script>
<button type="button" class="btn btn-lg btn-block"
        ng-click="openModal('myModalContent.html', false, 'sm')">
</button>

You can also try the built-in Selection widget, if might be enough for your use case (you can’t customize it much but it’ll display a modal and send commands).

Unfortunately, I need to include information from the original button press into the modal dialog so this probably won’t work for me.

I guess I’m going to have to spend time and learn this controller stuff :frowning:

@jjones offered me another solution which works quite well, you define a global variable that can be accessed by both.

Here is a link to his solution