Last active
December 21, 2015 15:29
-
-
Save comilab/6326947 to your computer and use it in GitHub Desktop.
AngularJSでTwitterもどきを作る
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<title>Twitterもどき</title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script> | |
</head> | |
<body ng-app ng-init="tweets = []; t='';"> | |
<form name="tweetForm"> | |
<textarea required="required" name="t" ng-model="t" ng-maxlength="140"></textarea> | |
<span>{{t.length}} / 140</span> | |
<ul class="errors" ng-show="tweetForm.$valid"> | |
<li ng-show="tweetForm.t.$error.required">Required!</li> | |
<li ng-show="tweetForm.t.$error.maxlength">Too long!</li> | |
</ul> | |
<button type="button" ng-click="tweets.push(t)" ng-disabled="tweetForm.$invalid">tweet</button> | |
</form> | |
<article ng-repeat="tweet in tweets">{{tweet}}</article> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment