So I was at a #WCAVL planning meeting today and was trying to come up with a talk idea, and noticed we haven’t had many JS submissions. I thought: “oh hey – maybe it’d be cool for me to do one comparing using the WP-API with React, Angular, Backbone, etc…” Someone said: “there’s no way you could fit that into one session.” I’m like “Watch me.”
SO anyways I dared myself to get posts from the WP-API with Angular in “less than 5 minutes.” Not too hard:
Also here’s an example comparing it to how it might work in React:
Update 1: Some co-working space friend asked for the React example without jQuery:
Update 2: I felt like I should leave a Backbone example here, cause WP ships with it and all…
(BTW I’m really not great at Backbone and I feel like my
PostsView could probably listen to model changes and then update it’s view and that would be better, but I didn’t know best practice for that)
By no means are these the “best way” to do anything or even super thought-through. But they work, and they’re ezpz, and it helps illustrate how easy it is to grab stuff with the WP-API.