Basic Query Service - Angular.js Sample



Click To Run


Click To Run

					  <ul>
						<li ng-repeat="doc in docs" class="data">
							
							<span style="display:none" class="dataid">{{doc.ContentID}}</span>
							  {{ doc.Content.DisplayName }} <br>
							  {{ doc.Attributes.Date }} <br>
							  
							   <span ng-bind-html="doc.Summary.Text"></span>
							  
							  <hr>
							  
						</li>
					  </ul>
					
		 
			//angular js  init
			window.app = angular.module('DLV', ['ngRoute']);
				app.filter("trust", ['$sce', function($sce) {
				  return function(htmlCode){
					return htmlCode;
				  }
				}]);
				
				app.controller('DLVc', function($scope,$sce) {
						$scope.docs=[];
						window.controllerScope=$scope;
						window.controllerSCE=$sce;
				});
				
			//run
					
			function Run() {
				
				$("#DLV").show();
				$(".firstTime").remove();

						var $scope=window.controllerScope;
						var $sce=window.controllerSCE;
						$scope.docs=[];
						var GeodiServerUrl=$("#serverUrl").val();
						var GeodiWsName= $("#wsName").val();
						var GeodiToken=$("#token").val();
						$.post(GeodiServerUrl+'/QueryHandler?op=Query',  {
									q:$("#q").val(),
									wsName:GeodiWsName,
									UserSession:GeodiToken,
									options: JSON.stringify ({ SummaryFill:true })
								},
								function(data) {
									$("#jsonResponse").html(json2html(data));
									for(var i=0;i<data.length;i++)
										data[i].Summary.Text=$sce.trustAsHtml(data[i].Summary.Text );
									$scope.docs=data;
									$scope.$apply();
								}
							, 'json')				
				
				
			 }