0

I'm developing an app with AngularJS. I have this function declared in the controller:

$scope.showModal = function(modalId){
    alert(modalId);
    $(modalId).openModal();
};

Then I have a hyperlink which calls this function:

<a ng-click="showModal('#modal{{jsonObject._id}}');" >link</a>

The JSON Object ID is "1". In the navigator, I can see that the HTML code of the link is this:

<a ng-click="showModal('#modal1');" >link</a>

But when I click the link, the alert shows this:

#modal{{jsonObject._id}}

Instead of "#modal1".

Am I doing something wrong?

Thanks in advance.

2
  • is jsonObject in your scope ? Commented Nov 20, 2015 at 13:29
  • 3
    Mixing angular and jquery that much is bad practice. You might be interested in angular-ui-bootstrap which offers angular-integrated modals Commented Nov 20, 2015 at 13:31

1 Answer 1

2

In the ng-click you are in the angular context, so you have not to use {{}}.

<a ng-click="showModal('#modal'+jsonObject._id);" >link</a>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.