Altus
Altus

Reputation: 1425

How to get last modified date in angular JS

I have an HTML file that has a list of items, these items have their own HTML file containing more info when clicked on. I basically want to dynamically determine the last modified date of each of these files.

I tried creating a $scope function that uses the $q.defer(), not sure if I did something wrong but it didn't work for me.

Upvotes: 1

Views: 3804

Answers (1)

Altus
Altus

Reputation: 1425

I manage to figure it out:

    $http({
        type: "GET",
        async: true,
        timeout: 5000,
        url : 'views/api/account.html',
        dataType : "html"
    }).success(function(data, status, headers, config){
        var date = Date(headers()['last-modified']);
        $rootScope.api_doc['account'] = date;
    });

To Get the headers you need to use the headers() function;

Upvotes: 1

Related Questions