﻿
{"id":7227,"date":"2018-03-24T23:49:50","date_gmt":"2018-03-24T23:49:50","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=7227"},"modified":"2018-03-24T23:49:50","modified_gmt":"2018-03-24T23:49:50","slug":"angularjs-http-servis-ile-sunucu-islemleri","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/angularjs-http-servis-ile-sunucu-islemleri\/","title":{"rendered":"AngularJS &#8211; $http Servis \u0130le Sunucu \u0130\u015flemleri"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Merhaba,<\/p>\n<p>Web tabanl\u0131 projelerde sunucu ile etkile\u015fime girmek i\u015fin esas noktas\u0131n\u0131 te\u015fkil etmektedir. AngularJS framework\u00fcnde sunucu ile etkile\u015fime girmemizi sa\u011flayan servis $http olarak ayarlanm\u0131\u015ft\u0131r. Bu i\u00e7eri\u011fimizde $http servisini t\u00fcm y\u00f6nleriyle ele alaca\u011f\u0131z.<\/p>\n<p>Makale s\u00fcrecinde Asp.NET MVC mimarisi \u00fczerinde server i\u015flemlerimizi ger\u00e7ekle\u015ftirece\u011fimizi ve a\u015fa\u011f\u0131daki &#8220;Personel&#8221; isimli class\u0131 ve &#8220;ServerController&#8221; isimli controller\u0131 \u00f6rnek olarak kullanaca\u011f\u0131m\u0131z\u0131 belirterek konuya ba\u015flayabiliriz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    class Personel\r\n    {\r\n        public string Adi { get; set; }\r\n        public string SoyAdi { get; set; }\r\n        public int PersonelNo { get; set; }\r\n    }\r\n<\/pre>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    public class ServerController : Controller\r\n    {\r\n        List&lt;Personel&gt; PersonelListesi = new List&lt;Personel&gt;\r\n        {\r\n                new Personel{ Adi = &quot;Gen\u00e7ay&quot;, SoyAdi = &quot;Y\u0131ld\u0131z&quot;, PersonelNo = 1 },\r\n                new Personel{ Adi = &quot;Mehmet&quot;, SoyAdi = &quot;\u0130lker&quot;, PersonelNo = 2 },\r\n                new Personel{ Adi = &quot;Naci&quot;, SoyAdi =&quot;Conker&quot;, PersonelNo = 3 },\r\n                new Personel{ Adi = &quot;Mustafa&quot;, SoyAdi = &quot;Y\u0131ld\u0131z&quot;, PersonelNo = 4 }\r\n        };\r\n        public ActionResult Index()\r\n        {\r\n            return View();\r\n        }\r\n        &#x5B;HttpGet()]\r\n        public JsonResult PersonelGetir()\r\n        {\r\n            return Json(PersonelListesi, JsonRequestBehavior.AllowGet);\r\n        }\r\n        public JsonResult PersonelEkle(Personel model)\r\n        {\r\n            PersonelListesi.Add(model);\r\n            return Json(PersonelListesi, JsonRequestBehavior.AllowGet);\r\n        }\r\n    }\r\n<\/pre>\n<h3>$http Servisi \u0130le Get \u0130\u015flemleri<\/h3>\n<p>$http servisini get i\u015flemlerinde a\u015fa\u011f\u0131daki \u00f6rnekte oldu\u011fu gibi kullanmaktay\u0131z.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;script src=&quot;~\/Scripts\/angular.min.js&quot;&gt;&lt;\/script&gt;\r\n    &lt;script&gt;\r\n        angular.module(&quot;UygulamaModule&quot;, &#x5B;])\r\n            .controller(&quot;UygulamaController&quot;, function ($scope, $http) {\r\n                $scope.PersonelleriGetir = function () {\r\n                    $http.get(&quot;@Url.Action(&quot;PersonelGetir&quot;, &quot;Server&quot;)&quot;).then(function (gelen) {\r\n                        $scope.TabloGoster = true;\r\n                        $scope.PersonelListesi = gelen.data;\r\n                    });\r\n                }\r\n            });\r\n    &lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;body ng-app=&quot;UygulamaModule&quot; ng-controller=&quot;UygulamaController&quot;&gt;\r\n    &lt;input type=&quot;button&quot; value=&quot;Personelleri Getir&quot; ng-click=&quot;PersonelleriGetir()&quot; \/&gt;\r\n    &lt;table ng-show=&quot;TabloGoster&quot;&gt;\r\n        &lt;thead&gt;\r\n            &lt;tr&gt;\r\n                &lt;th&gt;ID&lt;\/th&gt;\r\n                &lt;th&gt;Ad&lt;\/th&gt;\r\n                &lt;th&gt;Soyad&lt;\/th&gt;\r\n            &lt;\/tr&gt;\r\n        &lt;\/thead&gt;\r\n        &lt;tbody&gt;\r\n            &lt;tr ng-repeat=&quot;personel in PersonelListesi&quot;&gt;\r\n                &lt;td&gt;{{personel.PersonelNo}}&lt;\/td&gt;\r\n                &lt;td&gt;{{personel.Adi}}&lt;\/td&gt;\r\n                &lt;td&gt;{{personel.SoyAdi}}&lt;\/td&gt;\r\n            &lt;\/tr&gt;\r\n        &lt;\/tbody&gt;\r\n    &lt;\/table&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/03\/AngularJS-http-Servis-\u0130le-Sunucu-\u0130\u015flemleri.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/03\/AngularJS-http-Servis-\u0130le-Sunucu-\u0130\u015flemleri.gif\" alt=\"AngularJS - $http Servis \u0130le Sunucu \u0130\u015flemleri\" width=\"144\" height=\"150\" class=\"aligncenter size-full wp-image-7232\" \/><\/a><\/p>\n<h3>$http Servisi \u0130le Post \u0130\u015flemleri<\/h3>\n<p>$http ile post i\u015flemini a\u015fa\u011f\u0131daki \u00f6rnekte detayl\u0131ca ele alm\u0131\u015f bulunmaktay\u0131z.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;script src=&quot;~\/Scripts\/angular.min.js&quot;&gt;&lt;\/script&gt;\r\n    &lt;script&gt;\r\n        angular.module(&quot;UygulamaModule&quot;, &#x5B;])\r\n            .controller(&quot;UygulamaController&quot;, function ($scope, $http) {\r\n                $scope.PersonelEkle = function () {\r\n                    var Personel = {\r\n                        Adi: $scope.Adi,\r\n                        SoyAdi: $scope.SoyAdi,\r\n                        PersonelNo: $scope.PersonelNo\r\n                    };\r\n                    $http.post(&quot;@Url.Action(&quot;PersonelEkle&quot;, &quot;Server&quot;)&quot;, Personel)\r\n                        .then(function onSuccess(response) {\r\n                            $scope.TabloGoster = true;\r\n                            $scope.PersonelListesi = response.data;\r\n                        });\r\n                }\r\n            });\r\n    &lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;body ng-app=&quot;UygulamaModule&quot; ng-controller=&quot;UygulamaController&quot;&gt;\r\n    &lt;div&gt;\r\n        Ad\u0131 : &lt;input type=&quot;text&quot; ng-model=&quot;Adi&quot; \/&gt;\r\n        &lt;br \/&gt;\r\n        Soyad\u0131 : &lt;input type=&quot;text&quot; ng-model=&quot;SoyAdi&quot; \/&gt;\r\n        &lt;br \/&gt;\r\n        Personel No :&lt;input type=&quot;text&quot; ng-model=&quot;PersonelNo&quot; \/&gt;\r\n        &lt;input type=&quot;button&quot; value=&quot;Personel Ekle&quot; ng-click=&quot;PersonelEkle()&quot; \/&gt;\r\n    &lt;\/div&gt;\r\n\r\n    &lt;table ng-show=&quot;TabloGoster&quot;&gt;\r\n        &lt;thead&gt;\r\n            &lt;tr&gt;\r\n                &lt;th&gt;ID&lt;\/th&gt;\r\n                &lt;th&gt;Ad&lt;\/th&gt;\r\n                &lt;th&gt;Soyad&lt;\/th&gt;\r\n            &lt;\/tr&gt;\r\n        &lt;\/thead&gt;\r\n        &lt;tbody&gt;\r\n            &lt;tr ng-repeat=&quot;personel in PersonelListesi&quot;&gt;\r\n                &lt;td&gt;{{personel.PersonelNo}}&lt;\/td&gt;\r\n                &lt;td&gt;{{personel.Adi}}&lt;\/td&gt;\r\n                &lt;td&gt;{{personel.SoyAdi}}&lt;\/td&gt;\r\n            &lt;\/tr&gt;\r\n        &lt;\/tbody&gt;\r\n    &lt;\/table&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/03\/AngularJS-http-Servis-\u0130le-Sunucu-\u0130\u015flemleri-1.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/03\/AngularJS-http-Servis-\u0130le-Sunucu-\u0130\u015flemleri-1.gif\" alt=\"AngularJS - $http Servis \u0130le Sunucu \u0130\u015flemleri\" width=\"352\" height=\"268\" class=\"aligncenter size-full wp-image-7237\" \/><\/a><\/p>\n<p>Bir yaz\u0131m\u0131z\u0131nda sonuna gelmi\u015f bulunmaktay\u0131z.<\/p>\n<p>Sonraki yaz\u0131lar\u0131mda g\u00f6r\u00fc\u015fmek \u00fczere&#8230;<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar&#8230;<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Merhaba, Web tabanl\u0131 projelerde sunucu ile etkile\u015fime girmek i\u015fin esas noktas\u0131n\u0131 te\u015fkil etmektedir. AngularJS framework\u00fcnde sunucu ile etkile\u015fime girmemizi sa\u011flayan servis $http olarak ayarlanm\u0131\u015ft\u0131r. Bu i\u00e7eri\u011fimizde $http servisini t\u00fcm y\u00f6nleriyle ele alaca\u011f\u0131z. Makale s\u00fcrecinde&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":7002,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2022],"tags":[2142,2143,2139,2141,2024,2138,2140],"class_list":["post-7227","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-angularjs","tag-http-get","tag-http-get-islemleri","tag-http-servis","tag-http-servisi-ile-get-islemleri","tag-angularjs","tag-angularjs-http-servis","tag-angularjs-http"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/7227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=7227"}],"version-history":[{"count":0,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/7227\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media\/7002"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=7227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=7227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=7227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}