0

Is there a way to pass an angular object property to ngDialog modal window? It seems you cannot pass it like you can in normal html:

<img ng-src="{{ member.picture }}" alt="{{ member.name }}" ng-click="showModal(' member.id ')" /><br />

In the above, the first two object properties (member.picture and member.name) work normally and gets replaced with the actual content in the view, for example path/to/picture.jpg and Juha Untinen, but the third one is passed as a string literal to showModal().

How can I pass the actual contents of member.id, which has a numeric value like 1, 2, or 3? So that the final parameter would be for example: showModal(1)

If I do this: ng-click="showModal( {{ member.id }} )", I get this error:

Syntax Error: Token '{' invalid key at column 13 of the expression [showModal( {{ member.id }} )] starting at [{ member.id }} )].

Here's the ngDialog function in the controller:

$scope.showModal = function(param) {
    ngDialog.open({
        template: 'app/biography/bioModal' + param + ".html",
        className: 'ngdialog-theme-plain',
        showClose: true,
        scope: $scope
    });
};

That is for testing passing the parameter. In the final version, I hope to have one partial view, which has the details (name, picture, etc) filled depending on the id parameter passed to it.

Juha Untinen
  • 1,806
  • 1
  • 24
  • 40

1 Answers1

1

You are trying to pass a string as parameter, so member.id will not get resolved.

What you to do is to pass the parameter without quotes as

ng-click="showModal(member.id)"
Fracedo
  • 626
  • 7
  • 23