Created
March 12, 2014 12:35
-
-
Save yitsushi/9506058 to your computer and use it in GitHub Desktop.
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
var App = { | |
controllers: {}, | |
configuration: { | |
domain: "s.l", | |
protocol: "http" | |
}, | |
utils: {} | |
}; | |
(function UrlUtils (app) { | |
app.utils.url = { | |
get: function(path) { | |
return app.configuration.protocol + "://" + app.configuration.domain + path; | |
} | |
}; | |
})(App); | |
(function LinkController (app) { | |
app.controllers.Link = function ($scope) { | |
$scope.links = []; | |
$scope.addLink = function addLink () { | |
$scope.links.unshift({ | |
short: App.utils.url.get("/a4d56g"), | |
long: $scope.newLink, | |
clicks: 0, | |
created_at: new Date() | |
}); | |
$scope.newLink = ""; | |
return null; | |
}; | |
}; | |
app.controllers.Link.$inject = ['$scope']; | |
})(App); |
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
<html ng-app> | |
<head> | |
<link rel="stylesheet" href="stylesheets/main.css"> | |
<script type="text/javascript" src="javascripts/angular.min.js"></script> | |
<script type="text/javascript" src="javascripts/app.js"></script> | |
</head> | |
<body> | |
<div ng-controller='App.controllers.Link'> | |
<form ng-submit="addLink()"> | |
<input type="text" | |
ng-model="newLink" | |
placeholder="add new link here"> | |
<input type="submit" value="add"> | |
</form> | |
<table> | |
<tr> | |
<th>Short link</th> | |
<th>Target link</th> | |
<th>Clicks</th> | |
<th>Created at</th> | |
</tr> | |
<tr ng-repeat="link in links"> | |
<td><a href="{{link.short}}">{{link.short}}</a></td> | |
<td><a href="{{link.long}}">{{link.long}}</a></td> | |
<td>{{link.clicks}}</td> | |
<td>{{link.created_at}}</td> | |
</tr> | |
</table> | |
</div> | |
</body> | |
</html> |
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
html, body { | |
margin: 0; | |
padding: 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment