{"id":991,"date":"2019-02-14T12:23:37","date_gmt":"2019-02-14T09:23:37","guid":{"rendered":"https:\/\/global.bg\/en\/?p=991"},"modified":"2019-02-14T12:30:24","modified_gmt":"2019-02-14T09:30:24","slug":"a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii","status":"publish","type":"post","link":"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/","title":{"rendered":"Download of a third-party JavaScript library and a way to &#8220;hook&#8221; to the initialization of the Angular application. Example with Analytics.js. Part Two."},"content":{"rendered":"\n<p>In the <a href=\"https:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-i\/\">first part of this post<\/a>, the discussion was focused mainly around the different methods of dynamic download of a third-party JavaScript library in an <em>Angular<\/em> application. Here in this second post, we will be discussing the ways in which we can &#8220;hook&#8221; to the initialization of the <em>Angular<\/em> application and fulfill our programming logic. For illustration I will continue to use the example application from the first part, which I will quote again in several places in the current post.<\/p>\n\n\n\n<p>The code for the\nexample application is available at: <a href=\"https:\/\/github.com\/agyonov\/NgInitGA\">https:\/\/github.com\/agyonov\/NgInitGA<\/a><\/p>\n\n\n\n<p>The app itself is live\non: <a href=\"https:\/\/agyonov.github.io\/NgInitGA\">https:\/\/agyonov.github.io\/NgInitGA<\/a><\/p>\n\n\n\n<p>For those who have not\nread the first part or have forgotten it, the example is using <em>Google Analytics<\/em> and to make the example\nmore meaningful it is extended to allow for full tracking of users&#8217; actions in\nthe <em>Angular<\/em> application.<\/p>\n\n\n\n<p><strong>NB<\/strong>: As for tracking of users in <em>Angular<\/em> application, it has great,\nready-made libraries, such as <a href=\"https:\/\/github.com\/angulartics\/angulartics2\">angulartics2<\/a>, which you can use. Here the question is not\nto create another such library, but with an example to show a possible solution\nto the two questions set at the beginning of this post!<\/p>\n\n\n\n<h2 style=\"text-align:center\">&#8220;Hook&#8221;\nto initialization of an Angular application<\/h2>\n\n\n\n<p>I have found several\nmethods to run your initialization program logic (your script) when launching\nthe <em>Angular<\/em> application in the\nbrowser. I will list two of them in short, and the third one I will look at a\nlittle more closely.<\/p>\n\n\n\n<h3>1. Use the &#8220;forRoot&#8221; static method:<\/h3>\n\n\n\n<p>If you have a service\nin a separate <em>Angular<\/em>\n&#8220;feature&#8221; module, then perhaps the best and most established way is\nto use a static &#8220;forRoot&#8221; method. The method is called when you\nimport your &#8220;feature\u201d module into the main module of the Angular application.<\/p>\n\n\n\n<p>You can read in more\ndetail <a href=\"https:\/\/angular.io\/guide\/singleton-services#forroot\">here<\/a>\nand <a href=\"https:\/\/medium.com\/@chrishouse\/when-to-use-angulars-forroot-method-400094a0ebb7\">here<\/a>.<\/p>\n\n\n\n<h3>2. Calling your script in the ngOnInit method of the main AppComponent:<\/h3>\n\n\n\n<p>The most direct and\nnot complicated method is to run the script in the <em>ngOnInit<\/em> method of the main <em>AppComponent<\/em>\nin your <em>Angular<\/em> application. If it\nworks, apply it. If we use the example from the first part of the publication,\nwe have completed one method-&#8220;Loadscript&#8221;. This method should be\ncalled from your initialization code to start the download of third-party .js <em>Google Analytics<\/em> Library. In the <em>app.component.ts<\/em> code, this would appear\nas follows:<\/p>\n\n\n<pre class=\"prettyprint\"><code class=\"language-ts\">@Component({\n  selector: 'app-root',\n  templateUrl: '.\/app.component.html',\n  styleUrls: ['.\/app.component.scss']\n})\nexport class AppComponent implements OnInit {\n\n  title = 'NgInit';\n\n  constructor(private gas: GoogleAnalyticsService) {\n  }\n\n  ngOnInit(): void {\n    \/\/ Start down load of JS Library\n    this.gas.loadScript();\n  }\n}<\/code><\/pre>\n\n\n<p>Particularity, in the\nsample application and the use of <em>Google\nanalytics<\/em> for illustration, this technique will work without any problems.<\/p>\n\n\n\n<p><strong>A recital against<\/strong> its possible use in other cases is that there\nwould be situations <strong>where it would not\nhave done<\/strong> the job \u2639. These are the cases where all the\ninitializing logic must have <strong>completed\nits execution before the start of<\/strong> the <em>ngOnInit\nmethod<\/em> execution or any other code from your application.<\/p>\n\n\n\n<p>An example, for such a situation, is to say when you have a mandatory\nuser <strong>authentication<\/strong> and it must be\ncompleted, successful or not, before any other code from your Angular\napplication is executed.<\/p>\n\n\n\n<p>The user authentication scenario, in an Angular application, is an\ninteresting topic for which I can write a separate article in the future.<\/p>\n\n\n\n<h3>3. Using pre-defined in Angular tokens (the most interesting)<\/h3>\n\n\n\n<p>There is one way to\n&#8220;hook&#8221; to the <em>Angular<\/em>\napplication initialization process, about which, I believe, the information\nfrom the <em>Angular<\/em> team is shared in an\noverly &#8220;modest&#8221; manner. These are the so-called <em>predefined tokens<\/em> and &#8220;<em>Factory\nproviders<\/em>&#8220;. Information about them can be found <a href=\"https:\/\/angular.io\/guide\/dependency-injection-providers#predefined-tokens-and-multiple-providers\">here<\/a>\nand <a href=\"https:\/\/angular.io\/guide\/dependency-injection-providers#factory-providers\">here<\/a>.<\/p>\n\n\n\n<p>In the example\napplication, this approach is implemented into the <em>app.module.ts<\/em> file, the main module of the Angular application.<\/p>\n\n\n\n<p>At the beginning we\ndefine &#8220;factory&#8221; function <strong><em>GoogleAnalyticsServiceFactory<\/em><\/strong> and export it! The latter is important from\nthe perspective of <em>TypeScript<\/em> and AOT\ncompiling the <em>Angular<\/em> application.<\/p>\n\n\n\n<p>The function itself\nmust return another, internal function. That&#8217;s why it&#8217;s called factory \ud83d\ude0a.<\/p>\n\n\n\n<p>The internal function\nthat is returned by <strong><em>GoogleAnalyticsServiceFactory<\/em><\/strong> is your code that <strong>will be\nexecuted when initializing<\/strong> the <em>Angular<\/em>\napplication. The inner function can return in result <em>void<\/em> or <em>Promise<\/em>.<\/p>\n\n\n\n<p><strong>Note<\/strong>: If it returns <em>Promise<\/em>, the <em>Angular<\/em> app <strong>will be blocked<\/strong> until <em>Promise<\/em>\nis resolved!<\/p>\n\n\n\n<p>The internal function\ngets as input parameter (via dependency-injection) service <em>GoogleAnalyticsService<\/em> and executes the &#8220;<em>loadScript<\/em>&#8221; method. That&#8217;s what we were aiming for!<\/p>\n\n\n<pre class=\"prettyprint\"><code class=\"language-ts\">\/\/ Factory provider for Angular. Provides function to be executed on Angular application <br \/>\/\/startup\nexport const GoogleAnalyticsServiceFactory = (gas: GoogleAnalyticsService) =&gt; {\n  return () =&gt; {\n    \/\/ download\n    gas.loadScript();\n  };\n};\n\n@NgModule({\n  declarations: [\n    AppComponent,\n    SecondPageComponent,\n    HomeComponent\n  ],\n  imports: [\n    BrowserModule,\n    AppRoutingModule\n  ],\n  providers: [\n    \/\/ Provides function to be executed on Angular application startup\n    {\n      provide: APP_INITIALIZER,\n      useFactory: GoogleAnalyticsServiceFactory,\n      deps: [GoogleAnalyticsService],\n      multi: true\n    }\n  ],\n  bootstrap: [AppComponent]\n})\nexport class AppModule { }<\/code><\/pre>\n\n\n<p>In the <em>providers<\/em> array, when defining the <em>AppModule<\/em> main module of the <em>Angular<\/em> application, we figuratively\n&#8220;hook&#8221; the function defined above to the Angular startup process.<\/p>\n\n\n\n<p>This is done by using\nthe pre-defined <em>token<\/em> <strong>APP_INITIALIZER<\/strong>. It identifies all\nprovider marked with it to run before the <em>Angular<\/em>\napplication is initialized!<\/p>\n\n\n\n<p><em>Note<\/em> that as <em>dependency<\/em> (the array\n<strong>deps: [GoogleAnalyticsService]<\/strong>) are\nlisted the parameters that <em>Angular<\/em>\nbootstrap process must instantiates and submit as parameters to the function\nthat will run when the application starts!<\/p>\n\n\n\n<p>\u0410nd\nvoila! This time for real \ud83d\ude0a.<\/p>\n\n\n\n<h2 style=\"text-align:center\">Example\napplication<\/h2>\n\n\n\n<p>For assurance that the\nabove code is working, you can look at the live sample application. Try it!<\/p>\n\n\n\n<p>The following code\nsamples have also been added to the <em>GoogleAnalyticsService\n<\/em>service for accessing <em>Google Analytics<\/em>:<\/p>\n\n\n<p><\/p>\n<pre class=\"prettyprint\"><code class=\"language-ts\">\/\/ Send page view event to Google Analytics\n  public send(pageUrl: string): void {\n    \/\/ Send\n    window.ga('set', 'page', pageUrl);\n    window.ga('send', 'pageview');\n  }\n\n  \/\/ Send event tracking event to Google Analytics\n  public event(eventCategory: string, eventAction: string): void {\n    \/\/ Send\n    window.ga('send', 'event', eventCategory, eventAction);\n  }\n<\/code><\/pre>\n<p>These methods follow the instructions of <em>Google Analytics<\/em> to work with SPA applications.<\/p>\n<p>The methods are used by the <em>Home<\/em>, <em>Second Page<\/em> pages and the button <em>Just an Event<\/em> to send information to <em>Google Analytics<\/em> about the user&#8217;s actions.<\/p>\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/global.bg\/bg\/wp-content\/uploads\/2019\/02\/1-1024x753.png\" alt=\"1\" class=\"wp-image-935\"\/><\/figure>\n\n\n\n<p>It is visible from the above screen that:<\/p>\n\n\n\n<ol><li>The script\n<em>analytics.js<\/em> is downloaded from the\nbrowser<\/li><li>When\ntransitioning from page to page and pressing the button, a post of data to the <em>collect<\/em> address of <em>Google Analytics, <\/em>occurs.<\/li><\/ol>\n\n\n\n<h2 style=\"text-align:center\">Conclusion<\/h2>\n\n\n\n<p>In these two posts, I\nhave tried to examine and describe in words and examples three different\napproaches to achieving the objectives of both topics:<\/p>\n\n\n\n<ul><li>Download\nthe third-party <em>JavaScript<\/em> library in\n<em>Angular<\/em> application<\/li><li>&#8220;Hook&#8221;\nto the initializing of an <em>Angular<\/em>\napplication<\/li><\/ul>\n\n\n\n<p>I hope you have not\nbeen bored and that it will be helpful for you if you need to program things\nlike above mentioned, to choose an approach that best serves you.<\/p>\n\n\n\n<p>Author: Aleksandar Gyonov<\/p>\n\n\n<p><\/p>\n<p><script src=\"https:\/\/cdn.rawgit.com\/google\/code-prettify\/master\/loader\/run_prettify.js?skin=sons-of-obsidian\"><\/script><\/p>","protected":false},"excerpt":{"rendered":"<p>In the first part of this post, the discussion was focused mainly around the different methods of dynamic download of a third-party JavaScript library in an Angular application. Here in this second post, we will be discussing the ways in which we can &#8220;hook&#8221; to the initialization of the Angular application and fulfill our programming [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":993,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","inline_featured_image":false},"categories":[41],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>A way to &quot;hook&quot; to the initialization of the Angular application! Part II<\/title>\n<meta name=\"description\" content=\"GLOBAL CONSULTING - Download of a third-party JavaScript library and a way to &quot;hook&quot; to the initialization of the Angular application. Example with Analytics.js. Part Two.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A way to &quot;hook&quot; to the initialization of the Angular application! Part II\" \/>\n<meta property=\"og:description\" content=\"GLOBAL CONSULTING - Download of a third-party JavaScript library and a way to &quot;hook&quot; to the initialization of the Angular application. Example with Analytics.js. Part Two.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/\" \/>\n<meta property=\"og:site_name\" content=\"GLOBAL CONSULTING\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/global.bg\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-02-14T09:23:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-02-14T09:30:24+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/global.bg\/en\/wp-content\/uploads\/2019\/02\/Angular-Elements-Your-ngComponents-everywhere.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"480\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"alext\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@GlobalConsult19\" \/>\n<meta name=\"twitter:site\" content=\"@GlobalConsult19\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"alext\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/\"},\"author\":{\"name\":\"alext\",\"@id\":\"https:\/\/global.bg\/en\/#\/schema\/person\/f1d3ed6545a59e4ff50f600b1f54d565\"},\"headline\":\"Download of a third-party JavaScript library and a way to &#8220;hook&#8221; to the initialization of the Angular application. Example with Analytics.js. Part Two.\",\"datePublished\":\"2019-02-14T09:23:37+00:00\",\"dateModified\":\"2019-02-14T09:30:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/\"},\"wordCount\":1011,\"publisher\":{\"@id\":\"https:\/\/global.bg\/en\/#organization\"},\"articleSection\":[\"Articles\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/\",\"url\":\"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/\",\"name\":\"A way to \\\"hook\\\" to the initialization of the Angular application! Part II\",\"isPartOf\":{\"@id\":\"https:\/\/global.bg\/en\/#website\"},\"datePublished\":\"2019-02-14T09:23:37+00:00\",\"dateModified\":\"2019-02-14T09:30:24+00:00\",\"description\":\"GLOBAL CONSULTING - Download of a third-party JavaScript library and a way to \\\"hook\\\" to the initialization of the Angular application. Example with Analytics.js. Part Two.\",\"breadcrumb\":{\"@id\":\"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/global.bg\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Download of a third-party JavaScript library and a way to &#8220;hook&#8221; to the initialization of the Angular application. Example with Analytics.js. Part Two.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/global.bg\/en\/#website\",\"url\":\"https:\/\/global.bg\/en\/\",\"name\":\"GLOBAL CONSULTING\",\"description\":\"Make IT Global\",\"publisher\":{\"@id\":\"https:\/\/global.bg\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/global.bg\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/global.bg\/en\/#organization\",\"name\":\"Global Consulting Ltd | Make IT Global\",\"url\":\"https:\/\/global.bg\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/global.bg\/en\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/global.bg\/en\/wp-content\/uploads\/2017\/08\/GCPrimaryLogoHorizontalPositive-1.svg\",\"contentUrl\":\"http:\/\/global.bg\/en\/wp-content\/uploads\/2017\/08\/GCPrimaryLogoHorizontalPositive-1.svg\",\"caption\":\"Global Consulting Ltd | Make IT Global\"},\"image\":{\"@id\":\"https:\/\/global.bg\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/global-consulting-ltd\/\",\"https:\/\/www.facebook.com\/global.bg\/\",\"https:\/\/twitter.com\/GlobalConsult19\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/global.bg\/en\/#\/schema\/person\/f1d3ed6545a59e4ff50f600b1f54d565\",\"name\":\"alext\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/global.bg\/en\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/1.gravatar.com\/avatar\/dcefe2e0f629ed86ee7022824f7266b1?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/1.gravatar.com\/avatar\/dcefe2e0f629ed86ee7022824f7266b1?s=96&d=mm&r=g\",\"caption\":\"alext\"},\"url\":\"http:\/\/global.bg\/en\/author\/alext\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"A way to \"hook\" to the initialization of the Angular application! Part II","description":"GLOBAL CONSULTING - Download of a third-party JavaScript library and a way to \"hook\" to the initialization of the Angular application. Example with Analytics.js. Part Two.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/","og_locale":"en_US","og_type":"article","og_title":"A way to \"hook\" to the initialization of the Angular application! Part II","og_description":"GLOBAL CONSULTING - Download of a third-party JavaScript library and a way to \"hook\" to the initialization of the Angular application. Example with Analytics.js. Part Two.","og_url":"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/","og_site_name":"GLOBAL CONSULTING","article_publisher":"https:\/\/www.facebook.com\/global.bg\/","article_published_time":"2019-02-14T09:23:37+00:00","article_modified_time":"2019-02-14T09:30:24+00:00","og_image":[{"width":1024,"height":480,"url":"http:\/\/global.bg\/en\/wp-content\/uploads\/2019\/02\/Angular-Elements-Your-ngComponents-everywhere.jpg","type":"image\/jpeg"}],"author":"alext","twitter_card":"summary_large_image","twitter_creator":"@GlobalConsult19","twitter_site":"@GlobalConsult19","twitter_misc":{"Written by":"alext","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/#article","isPartOf":{"@id":"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/"},"author":{"name":"alext","@id":"https:\/\/global.bg\/en\/#\/schema\/person\/f1d3ed6545a59e4ff50f600b1f54d565"},"headline":"Download of a third-party JavaScript library and a way to &#8220;hook&#8221; to the initialization of the Angular application. Example with Analytics.js. Part Two.","datePublished":"2019-02-14T09:23:37+00:00","dateModified":"2019-02-14T09:30:24+00:00","mainEntityOfPage":{"@id":"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/"},"wordCount":1011,"publisher":{"@id":"https:\/\/global.bg\/en\/#organization"},"articleSection":["Articles"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/","url":"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/","name":"A way to \"hook\" to the initialization of the Angular application! Part II","isPartOf":{"@id":"https:\/\/global.bg\/en\/#website"},"datePublished":"2019-02-14T09:23:37+00:00","dateModified":"2019-02-14T09:30:24+00:00","description":"GLOBAL CONSULTING - Download of a third-party JavaScript library and a way to \"hook\" to the initialization of the Angular application. Example with Analytics.js. Part Two.","breadcrumb":{"@id":"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/global.bg\/en\/a-way-to-hook-to-the-initialization-of-the-angular-application-part-ii\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/global.bg\/en\/"},{"@type":"ListItem","position":2,"name":"Download of a third-party JavaScript library and a way to &#8220;hook&#8221; to the initialization of the Angular application. Example with Analytics.js. Part Two."}]},{"@type":"WebSite","@id":"https:\/\/global.bg\/en\/#website","url":"https:\/\/global.bg\/en\/","name":"GLOBAL CONSULTING","description":"Make IT Global","publisher":{"@id":"https:\/\/global.bg\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/global.bg\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/global.bg\/en\/#organization","name":"Global Consulting Ltd | Make IT Global","url":"https:\/\/global.bg\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/global.bg\/en\/#\/schema\/logo\/image\/","url":"http:\/\/global.bg\/en\/wp-content\/uploads\/2017\/08\/GCPrimaryLogoHorizontalPositive-1.svg","contentUrl":"http:\/\/global.bg\/en\/wp-content\/uploads\/2017\/08\/GCPrimaryLogoHorizontalPositive-1.svg","caption":"Global Consulting Ltd | Make IT Global"},"image":{"@id":"https:\/\/global.bg\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/company\/global-consulting-ltd\/","https:\/\/www.facebook.com\/global.bg\/","https:\/\/twitter.com\/GlobalConsult19"]},{"@type":"Person","@id":"https:\/\/global.bg\/en\/#\/schema\/person\/f1d3ed6545a59e4ff50f600b1f54d565","name":"alext","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/global.bg\/en\/#\/schema\/person\/image\/","url":"http:\/\/1.gravatar.com\/avatar\/dcefe2e0f629ed86ee7022824f7266b1?s=96&d=mm&r=g","contentUrl":"http:\/\/1.gravatar.com\/avatar\/dcefe2e0f629ed86ee7022824f7266b1?s=96&d=mm&r=g","caption":"alext"},"url":"http:\/\/global.bg\/en\/author\/alext\/"}]}},"_links":{"self":[{"href":"http:\/\/global.bg\/en\/wp-json\/wp\/v2\/posts\/991"}],"collection":[{"href":"http:\/\/global.bg\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/global.bg\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/global.bg\/en\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/global.bg\/en\/wp-json\/wp\/v2\/comments?post=991"}],"version-history":[{"count":4,"href":"http:\/\/global.bg\/en\/wp-json\/wp\/v2\/posts\/991\/revisions"}],"predecessor-version":[{"id":999,"href":"http:\/\/global.bg\/en\/wp-json\/wp\/v2\/posts\/991\/revisions\/999"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/global.bg\/en\/wp-json\/wp\/v2\/media\/993"}],"wp:attachment":[{"href":"http:\/\/global.bg\/en\/wp-json\/wp\/v2\/media?parent=991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/global.bg\/en\/wp-json\/wp\/v2\/categories?post=991"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/global.bg\/en\/wp-json\/wp\/v2\/tags?post=991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}