Questions tagged [amp-bind]
46 questions
4
votes
2 answers
Multiple dynamic classes with amp-bind
How do you include multiple dynamic classes in amp-bind?
For example:

teknova
- 857
- 1
- 6
- 12
3
votes
1 answer
Mapped state into amp-list [src]
I need to use a state as an input for the amp-list. But before that, I want to map the state (to perform some math or operations).
When mapping every position of the array into an object and put it into src, I cannot make it work (code…

AgoHH
- 180
- 1
- 14
2
votes
0 answers
AMP How to use amp-bind setState on item of amp-list
I want to update the quantity of a product in my cart. I do not want to use the default input type number because of the styling, thus have 2 buttons around my text input to update the quantity.
Here's my state:

Élyse
- 1,351
- 1
- 10
- 12
2
votes
1 answer
How to add an object to an amp-state array in AMP-HTML?
I have a state called currentItem with url, title, description... When I push a button, a currentItem should be saved in other state called myItems. It will contains a list of items objects.
The problem right now is that it always shows the last…

NoiK
- 162
- 1
- 11
2
votes
2 answers
How to set text content of amp-selector into amp-state
I would like to know how can I get the text content based on the option which a user selected and set it to amp-state.
For example, if a user selects "red" option. I want to set the "rouge" into amp-state not "red". I know that I can get value by…

shinyatk
- 855
- 11
- 28
2
votes
1 answer
Amp dropdown with other option
I have drop down of some choice where last option is "Other".
I want to display text field when user select other option from drop down.
I am using normal html, Sorry I am AMP beginner, I found some example of amp-list with json option, but i don't…

Jaysukh Maghodiya
- 349
- 4
- 11
2
votes
0 answers
AMP - multiple buttons to show/hide
I'm trying to change the state of two buttons.
But if I press one button both dissapear.
Button 1 should switch to Button 2 (and vice versa)
and
Button 3 to Button 4 (and vice versa)
but if I press one button the other dissapears
…

user3674177
- 58
- 6
2
votes
2 answers
How can I format a number as money in AMP-html?
I have some arbitrary number, which in my use-case is between 1,000 and 1,000,000. I need to format this value into a display value, in which it's being displayed as money. I.e 1000 -> "$1,000", 100000 ->"$100,000", etc.
The problem I'm having is…

nickrenfo2
- 85
- 1
- 10
2
votes
3 answers
Custom React Attributes with Brackets
In this answer it's explained how to use the undocumented is feature to add a custom attribute to a React element. However, I'd like to add an attribute for use with amp-bind which is surrounded by brackets. When I try this the attribute is not…

Gil Birman
- 35,242
- 14
- 75
- 119
1
vote
0 answers
How to Assign back submit-success JSON response to the clicked event in the PHP loop. amp-form, amp-bind
on submit-success, form returns a JSON response and I am trying to add the response to the clicked tag [class]="wishstatus" but it is getting added to all the tag since it is in the PHP loop.
is there any solution to add the JSON response to the…

Azcoding
- 11
- 1
1
vote
0 answers
CSS styles are not working on dynamic classes with amp-bind in NEXT.js
amp-bind-class to add 'active' class to buttons that are active.
And it's working perfectly when I see it through chrome developer tools but the only problem is that the CSS is not working on them.
I am using AMP in Next.js
{foo.map((item, i) => (
…

coderharshit
- 11
- 3
1
vote
0 answers
How to stop AMP from removing unused CSS classes?
I have noticed that AMP removes the unused CSS classes I have in my stylesheet. This prevents me from adding those classes to HTML elements using amp-bind when a user clicks a button.
on="submit-success: AMP.setState({'disliked_clicked':…

Fabian Amran
- 833
- 6
- 11
1
vote
1 answer
Dynamic setState in AMP
I have amp-state like this: