List of All Site Templates with REST API and AngularJS



Here is the code which can show you how to display all site templates / custom templates with use of REST API & AngularJS in SharePoint :


<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script> 
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script> 
     
<script> 
        var myAngApp = angular.module('SPAngGetSiteTemplate', []); 
        myAngApp.controller('SPAngGetSiteTemplateController', function ($scope, $http) { 
            $http({ 
                method: 'GET', 
                url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/getavailablewebtemplates(1033)?$orderby=Title", 
                headers: { "Accept": "application/json;odata=verbose" } 
            }).success(function (data, status, headers, config) { 
                $scope.customers = data.d.results; 
            }).error(function (data, status, headers, config) { 
           
            }); 
        }); 
</script> 


<div ng-app="SPAngGetSiteTemplate"> 
    <div ng-controller="SPAngGetSiteTemplateController" > 
        <table style="width: 100%;"> 
            <tr> 
                <th style="width: 30%;">Title</th> 
                <th style="width: 65%;">Name</th> 
            </tr> 
            <tr ng-repeat="customer in customers"> 
                <td style="">{{customer.Title}}</td> 
                <td>{{customer.Name}}</td> 
                </tr> 
        </table> 
    </div> 
</div>
  



Enjoy SharePoint Coding!!!
Gaurav Goyal

Comments

Popular Posts

SharePoint Interview Questions and Answers

Download Infopath Form Templates

How to get current logged user information using JavaScript ?

Steps to set Form based authentication (FBA) for SharePoint 2010

SharePoint Interview Questions and Answers II

Get List Items - JavaScript

Cross Site List Rollup Web Part for SharePoint 2010

Hide Recently Modified Items

Change Language for current user with JSOM in SharePoint Online

SharePoint 2010 CSS Chart