JSFiddle - React, Tailwind, and code Playground
by vvakame
HTML
<div ng-app="twitter">
<div ng-controller="Controller">
<ul>
<li ng-repeat="tweet in tweets">
{{tweet.from_user_name}} 「{{tweet.text}}」
<hr ng-show="!$last">
</li>
</ul>
</div>
</div>
JavaScript
angular.module("twitter", [], function () {
})
.factory("twitterService", function ($http) {
return new TwitterService($http);
});
function TwitterService($http) {
this.getList = function (word) {
return $http({
method: "JSONP",
url: "http://search.twitter.com/search.json?q=" + word + "&callback=JSON_CALLBACK"
});
};
}
function Controller($scope, twitterService) {
twitterService.getList("AngularJS").success(function(data) {
$scope.tweets = data.results;
});
};