Michael Baldry
Michael Baldry

Reputation: 2028

angular-dialogs-service scoping doesn't seem to work

I'm trying to get angular-dialogs-service creating a custom dialog, it works and shows with this code:

  opts =
    keyboard: false
    backdrop: "static"
    size: "sm"

  dialogs.create "modals/error.html", "errorController", {message: "Hello!"}, opts

In my error.html I have this, in an attempt to get my message to show:

<div class="modal-body text-danger">
  <p>{{data.message}}</p>
  <p>{{message}}</p>
  <p>{{$parent.message}}</p>
  <p>{{$parent.data.message}}</p>
</div>

none of these show the message, from what I can gather from the source and examples, data.message should work.

Can anyone shed some light on this for me?

Upvotes: 0

Views: 111

Answers (1)

Michael Baldry
Michael Baldry

Reputation: 2028

So I found my problem, the data passed to the dialogs service is not automatically assigned on the scope anywhere, in the example, which I missed, the controller for the dialog actually has the data injected, then assigns it on the scope.

MyApp.controller "errorController", ($scope, data) ->
  $scope.data = data

This has fixed my issue as you'd expect!

The way to bind to it, therefore is {{data.message}}

Upvotes: 1

Related Questions