Created
August 13, 2019 09:03
-
-
Save tristankirkpatrick/3cce03345f102473799583d4b375f178 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Vue({ | |
el: "#app", | |
data: function () { | |
return { | |
filter: "", | |
sort: "", | |
options: [ | |
{ label: "Recently Added", value: "none" }, | |
{ label: "Most Followers", value: "followers_count" }], | |
teachers: [] }; | |
}, | |
created() { | |
axios. | |
get("http://192.168.1.150:8080/twitterteachers/teachers"). | |
then(({ data }) => { | |
this.teachers = data; | |
}); | |
}, | |
computed: { | |
getTeachers() { | |
var teachers = this.teachers.filter(teacher => { | |
return teacher.name.toLowerCase().includes(this.filter.toLowerCase()); | |
}); | |
if (this.sort == "followers_count") { | |
return teachers.sort(function (a, b) { | |
return b.followers_count - a.followers_count; | |
}); | |
} else { | |
return teachers; | |
} | |
} } }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment