1

I'm trying to reference an amp-bind-macro expression (I need to use different amp-bind-expressions depending on user inputs).

Trouble is, when I try to reference them, it doesn't execute the expression. In the console it says syntax error. No matter what I try I can't get it working.

Here's an example of the code I'm trying to implement:

<amp-bind-macro id="exampleMacro" arguments="input" expression="8*input"></amp-bind-macro>

<amp-state id="exampleJson">
<script type="application/json">
 { "test": "exampleMacro" }
</script>
</amp-state>

<span [text]="[exampleJson.test](input)">0.0</span>

I've tried:

<span [text]="exampleJson.test(input)">0.0</span>
<span [text]="[exampleJson.test][(input)]">0.0</span>

Any ideas team? The AMP documentation says: "A macro can be invoked like a function by referencing its id attribute value from anywhere in your doc" https://amp.dev/documentation/components/amp-bind?referrer=ampproject.org#defining-macros-with-amp-bind-macro

So I would have thought it was possible to do this

1 Answer 1

1

As the example in the documentation link shows, amp-bind-macro can only be referenced by id in amp-bind expressions. E.g.

<span [text]="exampleMacro()">0.0</span>

Hope that helps!

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.