﻿
{"id":7716,"date":"2018-04-21T20:37:03","date_gmt":"2018-04-21T20:37:03","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=7716"},"modified":"2018-04-21T20:37:03","modified_gmt":"2018-04-21T20:37:03","slug":"angular-4-angular-notifications-entegrasyonu-ve-kullanimi","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/angular-4-angular-notifications-entegrasyonu-ve-kullanimi\/","title":{"rendered":"Angular 4 &#8211; Angular Notifications Entegrasyonu ve Kullan\u0131m\u0131"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Merhaba,<\/p>\n<p>Her web site uygulamas\u0131nda oldu\u011fu gibi Angular uygulamalar\u0131nda da belirli i\u015flemler neticesinde son kullan\u0131c\u0131ya iletilmesi gereken bildiriler mevcuttur ve bu bildirileri kullan\u0131c\u0131n\u0131n etkile\u015fimine e\u015flik edecek g\u00f6rsellikte sunaca\u011f\u0131m\u0131z yap\u0131lara ihtiyac\u0131m\u0131z vard\u0131r. <\/p>\n<p>Bu yap\u0131larda standart html elemanlar\u0131 tercih edilebilirken daha geli\u015fmi\u015f componentlerede ba\u015fvurulabilir. \u0130\u015fte bu componentlerden Angular i\u00e7in tasarlanm\u0131\u015f olan &#8216;<strong>Angular Notifications<\/strong>&#8216; componenti \u00fczerine konu\u015fuyor olaca\u011f\u0131z ve bir Angular projesine entegrasyonunun nas\u0131l sa\u011fland\u0131\u011f\u0131 ve kullan\u0131ld\u0131\u011f\u0131 \u00fczerine detayl\u0131 irdelemede bulunaca\u011f\u0131z.<\/p>\n<h4>Projeye Angular Notifications Entegrasyonu<\/h4>\n<p>\u0130lk olarak Angular uygulamas\u0131na &#8216;Angular Notifications&#8217; entegrasyonunu ger\u00e7ekle\u015ftirebilme \u00fczerinde dural\u0131m. Bu i\u015flem i\u00e7in \u00f6ncelikle &#8220;package.json&#8221; dosyas\u0131ndaki &#8220;dependencies&#8221; \u00f6zelli\u011fine &#8220;angular2-notifications&#8221; referans\u0131n\u0131 eklememiz gerekmektedir.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n.\r\n.\r\n.\r\n  &quot;dependencies&quot;: {\r\n    &quot;@angular\/animations&quot;: &quot;^5.2.0&quot;,\r\n    &quot;@angular\/common&quot;: &quot;^5.2.0&quot;,\r\n    &quot;@angular\/compiler&quot;: &quot;^5.2.0&quot;,\r\n    &quot;@angular\/core&quot;: &quot;^5.2.0&quot;,\r\n    &quot;@angular\/forms&quot;: &quot;^5.2.0&quot;,\r\n    &quot;@angular\/http&quot;: &quot;^5.2.0&quot;,\r\n    &quot;@angular\/platform-browser&quot;: &quot;^5.2.0&quot;,\r\n    &quot;@angular\/platform-browser-dynamic&quot;: &quot;^5.2.0&quot;,\r\n    &quot;@angular\/router&quot;: &quot;^5.2.0&quot;,\r\n    &quot;core-js&quot;: &quot;^2.4.1&quot;,\r\n    &quot;rxjs&quot;: &quot;^5.5.6&quot;,\r\n    &quot;zone.js&quot;: &quot;^0.8.19&quot;,\r\n    &quot;angular2-notifications&quot;: &quot;1.0.1&quot;\r\n  },\r\n.\r\n.\r\n.\r\n<\/pre>\n<p>Ard\u0131ndan &#8220;Integrated Terminal&#8221; penceresinden &#8220;npm install&#8221; komutunu \u00e7al\u0131\u015ft\u0131rarak &#8220;package.json&#8221; dosyas\u0131nda olup uygulamada olmayan paketleri projeye y\u00fckleyelim.<br \/>\n<a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/04\/Angular-4-Angular-Notifications-Entegrasyonu-ve-Kullan\u0131m\u0131.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/04\/Angular-4-Angular-Notifications-Entegrasyonu-ve-Kullan\u0131m\u0131.png\" alt=\"Angular 4 - Angular Notifications Entegrasyonu ve Kullan\u0131m\u0131\" width=\"932\" height=\"71\" class=\"aligncenter size-full wp-image-7722\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/04\/Angular-4-Angular-Notifications-Entegrasyonu-ve-Kullan\u0131m\u0131.png 932w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/04\/Angular-4-Angular-Notifications-Entegrasyonu-ve-Kullan\u0131m\u0131-300x23.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/04\/Angular-4-Angular-Notifications-Entegrasyonu-ve-Kullan\u0131m\u0131-768x59.png 768w\" sizes=\"auto, (max-width: 932px) 100vw, 932px\" \/><\/a><\/p>\n<p>Art\u0131k &#8220;angular2-notifications&#8221; paketi uygulamam\u0131za y\u00fcklendi\u011fine g\u00f6re programatik \u00e7al\u0131\u015fmaya ba\u015flayabiliriz.<\/p>\n<h4>Angular Notifications Kullan\u0131m\u0131<\/h4>\n<p>\u0130lk olarak; varsay\u0131lan mod\u00fcl dosyas\u0131 olan &#8220;app.module.ts&#8221; dosyas\u0131na giderek a\u015fa\u011f\u0131daki \u00e7al\u0131\u015fmay\u0131 ger\u00e7ekle\u015ftiriyoruz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nimport { BrowserModule } from '@angular\/platform-browser';\r\nimport { NgModule } from '@angular\/core';\r\nimport { NotificationsService, SimpleNotificationsModule } from &quot;angular2-notifications&quot;;\r\nimport { AppComponent } from '.\/app.component';\r\n@NgModule({\r\n  declarations: &#x5B;\r\n    AppComponent\r\n  ],\r\n  imports: &#x5B;\r\n    BrowserModule,\r\n    SimpleNotificationsModule.forRoot()\r\n  ],\r\n  providers: &#x5B;NotificationsService],\r\n  bootstrap: &#x5B;AppComponent]\r\n})\r\nexport class AppModule { }\r\n<\/pre>\n<p>Burada dikkat ederseniz e\u011fer biraz \u00f6nce y\u00fcklemi\u015f oldu\u011fumuz &#8220;angular2-notifications&#8221; isimli paket i\u00e7erisindeki &#8220;NotificationsService&#8221; ve &#8220;SimpleNotificationsModule&#8221; isimli s\u0131n\u0131flar\u0131 import ediyoruz. Bu s\u0131n\u0131flardan &#8220;SimpleNotificationsModule&#8221; isimli olan\u0131 uygulamaya d\u0131\u015far\u0131dan laz\u0131m olan yap\u0131lar\u0131 import edece\u011finden dolay\u0131 &#8220;imports&#8221; \u00f6zelli\u011fine &#8220;SimpleNotificationsModule.forRoot()&#8221; \u015feklinde \u00e7a\u011f\u0131rarak tan\u0131ml\u0131yoruz. En nihayetinde &#8220;.forRoot&#8221; metodu bu nesne i\u00e7erisinde import edilmesi gereken ilgili yap\u0131lar\u0131 elde etmemizi sa\u011flamaktad\u0131r.<\/p>\n<p>&#8220;NotificationsService&#8221; s\u0131n\u0131f\u0131 ise notifikasyon i\u015fleminde kullanaca\u011f\u0131m\u0131z servis nesnesini kullan\u0131laca\u011f\u0131 yere constructerdan sunaca\u011f\u0131 i\u00e7in &#8220;providers&#8221; \u00f6zelli\u011fine tan\u0131mlayarak global eri\u015filebilir hale getiriyoruz.<\/p>\n<p>S\u0131ra \u00fczerinde \u00e7al\u0131\u015faca\u011f\u0131m\u0131z html sayfas\u0131na notifikasyona ait &#8220;selector&#8221; deyimini vermeye geldi. \u00d6rnekte &#8220;app.component.html&#8221; dosyas\u0131 \u00fczerinde \u00e7al\u0131\u015f\u0131ld\u0131\u011f\u0131 i\u00e7in ilgili i\u015flemi bu dosya \u00fczerinde \u00f6rneklendiriyoruz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n&lt;input type=&quot;text&quot; #txtAdSoyad \/&gt;\r\n&lt;button (click)=&quot;AdSoyadGoster(txtAdSoyad.value)&quot;&gt;G\u00f6ster&lt;\/button&gt;\r\n&lt;br&gt;\r\n&lt;simple-notifications &#x5B;options]=&quot;notificationOptions&quot;&gt;&lt;\/simple-notifications&gt;\r\n<\/pre>\n<p>Burada dikkat ederseniz e\u011fer &#8220;simple-notifications&#8221; niteli\u011fi notifikasyon \u00f6zelli\u011fini temsil etmektedir. Olu\u015fturulacak notifikasyonun ayarlar\u0131n\u0131 ise [options] attributeu ile tan\u0131mlanan &#8220;notificationOptions&#8221; isimli ilgili html dosyas\u0131n\u0131n component class\u0131ndan beslenen de\u011fi\u015fkenle ger\u00e7ekle\u015ftirmekteyiz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nimport { Component } from '@angular\/core';\r\nimport { NotificationsService } from 'angular2-notifications';\r\n@Component({\r\n  selector: 'app-root',\r\n  templateUrl: '.\/app.component.html',\r\n  styleUrls: &#x5B;'.\/app.component.css']\r\n})\r\nexport class AppComponent {\r\n  constructor(private notificationsService: NotificationsService) { }\r\n  public notificationOptions = {\r\n    timeOut: 3000, \/\/3 saniye g\u00f6z\u00fckecek.\r\n    position: &#x5B;&quot;top&quot;, &quot;right&quot;], \/\/Yukar\u0131da, sa\u011fda g\u00f6sterilecek.\r\n    lastOnBottom: true\r\n  }\r\n  AdSoyadGoster(text: string) {\r\n    this.notificationsService.success(&quot;Ad Soyad&quot;, text);\r\n  }\r\n}\r\n<\/pre>\n<p>Ayriyetten butonun click event\u0131na ba\u011flanan &#8220;AdSoyadGoster&#8221; fonksiyonu tetiklendi\u011fi zaman constructerdan gelen &#8220;NotificationsService&#8221; nesnesi \u00fczerinden &#8220;.success&#8221; fonksiyonu ile notifikasyon devreye sokulmaktad\u0131r. <\/p>\n<p>&#8220;success&#8221; fonksiyonuyla beraber di\u011fer yap\u0131sal notifikasyon fonksiyonlar\u0131n\u0131da a\u015fa\u011f\u0131da ele al\u0131rsak e\u011fer;<\/p>\n<table>\n<thead>\n<tr>\n<th>Fonksiyon<\/th>\n<th>A\u00e7\u0131klama<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>alert<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>error<\/td>\n<td>Ba\u015far\u0131s\u0131zl\u0131k, olumsuzluk durumlar\u0131nda kullan\u0131l\u0131r.<\/td>\n<\/tr>\n<tr>\n<td>info<\/td>\n<td>Bilgi verilirken kullan\u0131l\u0131r.<\/td>\n<\/tr>\n<tr>\n<td>warn<\/td>\n<td>Uyar\u0131, ikaz durumlar\u0131nda kullan\u0131l\u0131r.<\/td>\n<\/tr>\n<tr>\n<td>success<\/td>\n<td>\u0130\u015flem ba\u015far\u0131l\u0131ysa kullan\u0131l\u0131r.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u015feklinde tarif edebiliriz.<\/p>\n<p>T\u00fcm bu i\u015flemleri ger\u00e7ekle\u015ftirdikten sonra uygulamay\u0131 kaydedip yay\u0131nlad\u0131\u011f\u0131n\u0131zda a\u015fa\u011f\u0131daki gibi bildiri yap\u0131lanmas\u0131yla kar\u015f\u0131la\u015fabilirsiniz.<br \/>\n<a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/04\/Angular-4-Angular-Notifications-Entegrasyonu-ve-Kullan\u0131m\u0131.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/04\/Angular-4-Angular-Notifications-Entegrasyonu-ve-Kullan\u0131m\u0131.gif\" alt=\"Angular 4 - Angular Notifications Entegrasyonu ve Kullan\u0131m\u0131\" width=\"568\" height=\"302\" class=\"aligncenter size-full wp-image-7735\" \/><\/a><\/p>\n<p>Evet. Bu i\u00e7eri\u011fimizde de olduk\u00e7a kullan\u0131\u015fl\u0131 ve gayet \u015f\u0131k olan Angular Notifications \u00fczerine detayl\u0131 bir entegrasyon makalesi olu\u015fturmu\u015f olduk.<\/p>\n<p>Faydalanman\u0131z ve yarar\u0131n\u0131 Angular uygulamalar\u0131nda bol bol g\u00f6rmeniz dile\u011fiyle&#8230;<br \/>\nSonraki yaz\u0131lar\u0131mda g\u00f6r\u00fc\u015fmek \u00fczere&#8230;<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar dilerim&#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, Her web site uygulamas\u0131nda oldu\u011fu gibi Angular uygulamalar\u0131nda da belirli i\u015flemler neticesinde son kullan\u0131c\u0131ya iletilmesi gereken bildiriler mevcuttur ve bu bildirileri kullan\u0131c\u0131n\u0131n etkile\u015fimine e\u015flik edecek g\u00f6rsellikte sunaca\u011f\u0131m\u0131z yap\u0131lara ihtiyac\u0131m\u0131z vard\u0131r. Bu yap\u0131larda standart&#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":7246,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2144],"tags":[2274,2273,2275,2276,2277,2187,2278,2280,2279,2282,2281],"class_list":["post-7716","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-angular-4","tag-angular-4-angular-notifications","tag-angular-notifications","tag-angular-notifications-entegrasyonu","tag-angular-notifications-kullanimi","tag-angular2-notifications","tag-integrated-terminal","tag-ngular2-notifications","tag-notificationsservice","tag-npm-install","tag-simple-notifications","tag-simplenotificationsmodule"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/7716","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=7716"}],"version-history":[{"count":0,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/7716\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media\/7246"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=7716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=7716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=7716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}