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  :   6     Total  :    9837

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 January 15, 00:25
How To Enable Target Value And Actual Value In #D3 Gauge Chart

Twitter January 15, 00:24
How To Open #SharePoint List Hyperlink Column In Modal #Popup Window

Twitter January 15, 00:24
Quick Introduction To #Asp.NetCore And It’s Features

Twitter January 15, 00:22
How To Configure #PerformancePoint Services To Use Secure Store In #SharePoint 2013

Twitter January 15, 00:21
How To Block Or Disable #Office365 Services

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