ICAR logo

ICAR Master Data

(Agricultural Knowledge Resources and Information System Hub for Innovations)
ICAR RESEARCH DATA REPOSITORY FOR KNOWLEDGE MANAGEMENT

REST Example

This page providing few example of consuming JSON data access from KRISHI Master vocabulary website.

JSON data use to populate dropdown box by AngularJS :
1. Access SMD using REST api
PROCEDURE to Write Script for using JSON with AngularJS
STEP - I : Put on top AngularJS URL
   
				<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"> </script>
			
STEP - II : Write App code
				< script >
					var app = angular.module('ngoptionsApp', [])				
					app.controller('smdJson', function ($scope,$http) {	
						$scope.usersData = new Array;					
						$http.get("//krishi.icar.gov.in/MasterVocab/WEB/GetUrl/smd").success(function(response_smd)
					    		{
					    			$scope.usersData = response_smd.SMD;
					    			$scope.listSmd = $scope.usersData;
					    		});
					})
				</script>
			
STEP - III : Use app into DIV
				<div ng-app="ngoptionsApp">
			    	<select ng-controller="smdJson" name="ngvalueselect">
			        	<option value=""> --Select SMD-- </option>
			        	<option ng-repeat="smd in listSmd" ng-value="{{smd.smdId}}">{{smd.smdName}}</option>
				 	</select>
				 </div>
			
Download full Example and rename RESTexample.txt to RESTexample.html and run on HTTP web server.


Important Links