In angular you can do something like this?

It is necessary to check the availability of season subscriptions user subscriptions come with array.
3ea70474822b4b76a1d7adb40f62d0a3.png
How to do that?
July 8th 19 at 11:20
3 answers
July 8th 19 at 11:22
To start, try to answer the question "How in JavaScript you can do this?"
Maybe the answer will come by itself
July 8th 19 at 11:24
<div ng-if="current_user.subscriptions.season">...</div>
tried, not working - Chaim27 commented on July 8th 19 at 11:27
Perhaps you meant ng-if="current_user.subscriptions.indexOf(season) != -1". It is not clear that this season in your code. - tanya.Bartell commented on July 8th 19 at 11:30
: season is an object of the user to the subscription - object array - Chaim27 commented on July 8th 19 at 11:33
: apparently, I have to guess what the object is. No, I couldn't. Give examples of real data to make a more substantive discussion, rather than attempting telepathy. - tanya.Bartell commented on July 8th 19 at 11:36
ng-if="current_user.subscriptions.some(subscription => subscription._id == season._id)" - but instead use the _id field, which can be compared. - tanya.Bartell commented on July 8th 19 at 11:39
July 8th 19 at 11:26
1. Such conditions in the template it is better not to write.
2. Make a method in the scope isUserSubscribedTo(current_user, season).
3. https://developer.mozilla.org/ru/docs/Web/JavaScri...

Find more questions by tags JavaScriptAngular