SharePoint Pals
 | Sign In
How to create a weather widget using Angular Js and open weather map
by Sriram Varadarajan 16 Mar 2015
Enterprise Architect
Today  :   13     Total  :    8806

In this article, let us see, How to create a web based weather widget using Angular JS. Copy the below Javascript snippet and save it as script file with .js as extension. In this example I am using Chennai as the location. Open Weather Map api is used to fetch weather details


 var app = angular.module('weatherApp', []);
 app.controller('weatherCtrl', ['$scope', 'weatherService', function($scope, weatherService) {
     function fetchWeather(zip) {
         weatherService.getWeather(zip).then(function(data) {
             $ = data;
     $scope.findWeather = function(zip) {
         $ = '';
 app.factory('weatherService', ['$http', '$q', function($http, $q) {
             function getWeather(zip) {
                 var deferred = $q.defer();
                 $http.get('http: //’)
                     .success(function(data) {
                     .error(function(err) {
                         console.log('Error retrieving markets');
                     return deferred.promise;
                 return {
                     getWeather: getWeather


 <!DOCTYPE html>
 <html ng-app="weatherApp">
     <meta charset="utf-8″ />
       AngularJS Plunker
     <link data-require="bootstrap-css@3.1.1″ data-semver="3.1.1″ rel="stylesheet" href="//" />
       document.write(‘<base href="‘ + document.location + ‘" />’);
     <link rel="stylesheet" href="style.css" />
     <script data-require="angular.js@1.2.x" src="; data-semver="1.2.16″>
     <script data-require="jquery@*" data-semver="2.0.3″ src="">
       <script data-require="bootstrap@*" data-semver="3.1.1″ src="//">
   <script src="app.js">
 <body ng-controller="weatherCtrl">
     <div class="form-group">
       <input class="form-control" type="number" ng-model="zip" placeholder="e.g. 84105″ />
       <input class="btn btn-default" type="submit" value="Search" ng-click="findWeather(zip)" />
   <p ng-show="zip">
     Searching the forecasts for: {{zip}}
       Forecast For {{}}
     <div class="col-xs-6″>
       <div class="panel panel-primary">
         <div class="panel-heading">
             <img class="img-thumbnail forecast-img" ng-src="{{ place.list[0].weather[0].icon }}.png" />
         <div class="panel-body">
             H: {{ place.list[0] }}° C

Create a HTML code and copy and paste the below code: (this will show weather as well as image of the weather)

blog comments powered by Disqus

SharePoint Pals

SharePoint Pals, a community portal for SharePoint developers, Administrators and End Users. Let's join hands and share the point together.
Read this on mobile


Angular Js Training In Chennai
Advanced Angular Js training with real world developer scenarios
Angular Js, Web Api and Ionic for .Net Developers
All in one client side application development for .Net developers
Angular Js For SharePoint Developers
Get ready for the future. Its no more just C#

Get Connected

SharePoint Resources

SharePoint 2013 and 2010 Web Parts
Free Web Parts with Source Code for SharePoint Community

SharePoint 2013 Books and Tutorials
Collection of free SharePoint 2013 books and tutorials (eBooks, pdfs)

Supported By

Contribute your article and be eligible for a one month Free Subscription for Plural Sight. The Author of the most popular New Article (published in the previous month) will be awarded with a Free One month Plural Sight Subscription. Article can be sent to in a word document.

Related Resources

Recent Tweets

Twitter October 23, 22:21
How to Add/Remove User Custom Actions (in Site Actions Menu) Programmatically using CSOM PNP in SharePoint -

Twitter October 21, 21:34
How to Add a JS Link Reference to the Display Form or Any other ASPX Programmatically using CSOM PNP in SharePoint -

Twitter October 20, 13:01
How to Add a JS Link Reference to the NewForm and EditForm Programmatically using CSOM PNP in SharePoint Office 365-

Twitter October 12, 12:15
How to Deploy Provider Hosted Apps (Add-Ins) by App Stapling in SharePoint Office 365 -

Twitter October 11, 13:39
How to Deploy Provider HostedApp programmatically using CSOM in SharePoint Office 365 Activating Developer Feature -

Follow us @SharePointPals
Note: For Customization and Configuration, CheckOutRecent Tweets Documentation