Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Improvement of that handles generated title attribute on timeago tags.
<html ng-app="MyApplication">
<script src=""></script>
<script src="timeago-angular.js" type="text/javascript"></script>
<script src="my-app.js" type="text/javascript"></script>
<div ng-controller="myController">
<span class="time-ago" title="{{ myTime }}"></span>
angular.module('MyApplication', ['timeAgo'])
.controller('myController', function($scope) {
$scope.myTime = "2008-07-17T09:24:17Z";
angular.module('timeAgo', [])
.directive("timeAgo", function($q) {
return {
restrict: "C",
scope: {
title: '@'
link: function(scope, element, attrs) {
// Using deferred to assert we only initialize timeago() once per
// directive.
var parsedDate = $q.defer();
parsedDate.promise.then(function() {
attrs.$observe('title', function(newValue) {

This comment has been minimized.

Show comment Hide comment

5cell Aug 25, 2013

Very useful directive. Thank you!

5cell commented Aug 25, 2013

Very useful directive. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment