0

I have a link with handler in HTML:

<div class="menu-item" ng-repeat="pageName in pages">
    <a ng-click="routing.open('{{pageName}}')">{{pageName}}</a>
</div>

It triggers the 'open' function in a self-made Angular-UI Routing Factory / helper and sends the 'pageName' as param. The open method checks if there's a handler or state for loading a view.

var availableStates = $state.get();
    if (!pages[name] || availableStates.indexOf(name) === -1) {
        alert("State or Loader for state: '{0}' does not exist!".format(name));
        return;
    }

When clicked the alert shows with this message: enter image description here

But when I look in the web console, the value has been set properly. enter image description here

I could use some help with this, what causes this behaviour and how does one fix this?

1 Answer 1

2

You should not use {{ }} inside ng expressions. Replace

ng-click="routing.open('{{pageName}}')">

with

ng-click="routing.open(pageName)">

The reason for this is that you should consider all the specialized "ng-like" expressions as already enclosed in {{ }}, since they are already evaluated as angular expressions. You should only use {{ }} when you want to tell angular that you want the content enclosed on the double brackets to be evaluated as an angular expression.

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.