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
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!