{"id":10679,"date":"2016-02-11T16:11:13","date_gmt":"2016-02-11T14:11:13","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=10679"},"modified":"2016-02-06T13:50:29","modified_gmt":"2016-02-06T11:50:29","slug":"learning-angular-2-creating-tabs-component","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/","title":{"rendered":"Learning Angular 2: Creating a tabs component"},"content":{"rendered":"<p>This is a follow-up article of\u00a0<a href=\"http:\/\/blog.thoughtram.io\/angular\/2015\/04\/09\/developing-a-tabs-component-in-angular-2.html\" target=\"blank\">thoughtram&#8217;s excellent article on developing a tabs component with Angular 2<\/a>, where we&#8217;re going to explore an alternative way of creating a tab component by learning about\u00a0<code>@ContentChildren<\/code> and\u00a0<code>AfterContentInit<\/code>.<\/p>\n<p>That said, definitely read <a href=\"http:\/\/blog.thoughtram.io\/angular\/2015\/04\/09\/developing-a-tabs-component-in-angular-2.html\">thoughtram&#8217;s article on how to develop a tabs component in Angular 2<\/a> first. Then come back and continue here <img decoding=\"async\" title=\":smiley:\" src=\"https:\/\/assets.github.com\/images\/icons\/emoji\/unicode\/1f603.png\" alt=\"\" width=\"20\" height=\"20\" align=\"absmiddle\" \/>.<\/p>\n<p>Ok, to recap, the API of the tabs component looks as follows:<\/p>\n<pre class=\" brush:php\">&lt;tabs&gt;\r\n  &lt;tab tabTitle=\"Tab 1\"&gt;Tab 1 Content&lt;\/tab&gt;\r\n  &lt;tab tabTitle=\"Tab 2\"&gt;Tab 2 Content&lt;\/tab&gt;\r\n&lt;\/tabs&gt;<\/pre>\n<p>Whenever a user clicks on the tab header, the <code>&lt;tabs&gt;<\/code> component takes care of setting that specific tab to be visible and to hide all others. That&#8217;s why we need to establish a communication between the parent <code>&lt;tabs&gt;<\/code> and its children <code>&lt;tab&gt;<\/code>.<\/p>\n<p>For establishing a communication between the two components, the thoughtram article uses Angular 2&#8217;s powerful <strong>dependency injection<\/strong> which allows us to simply ask for an instance of a parent component. In the <code>&lt;tab&gt;<\/code> child component it simply asked for its parent <code>&lt;tabs&gt;<\/code> and registered itself on that parent component, using the <code>addTab<\/code> function:<\/p>\n<pre class=\" brush:php\">class Tab {\r\n  constructor(tabs: Tabs) {\r\n    tabs.addTab(this)\r\n  }\r\n}<\/pre>\n<p>This is one way of doing it. In fact, as Pascal says:<\/p>\n<blockquote><p>Angular 2 is so awesome that there is not just one way how to do things!<\/p>\n<p>We can take a totally different approach how to implement our simple tabs ( which isn\u2019t so easily possible in Angular 1 ), leveraging special Angular 2 @ContentChildren property decorator with QueryList type and AfterContentInit life cycle interface. Those are more advanced concepts, which we will cover in future articles.<\/p><\/blockquote>\n<h2>The alternative approach<\/h2>\n<p>This article is just about continuing thoughtram&#8217;s example, but without using the dependency injection approach. So basically, rather than getting a reference to our parent component <code>Tabs<\/code> in the child component <code>Tab<\/code> (<code>child =&gt; parent<\/code>), we&#8217;re doing it the other way round: we&#8217;ll get a reference to all of the <code>Tab<\/code> child components from the parent <code>Tabs<\/code> (<code>parent =&gt; child<\/code>).<\/p>\n<p>If you open the Tabs component, you can see that the child <code>&lt;tab&gt;<\/code> components are projected into it&#8217;s template via the <a href=\"http:\/\/juristr.com\/blog\/2016\/01\/ng2-multi-content-projection\">content projection<\/a> mechanism using <code>&lt;ng-content&gt;<\/code>.<\/p>\n<pre class=\" brush:php\">...\r\n@Component({\r\n  selector: 'tabs',\r\n  template:`\r\n    &lt;ul class=\"nav nav-tabs\"&gt;\r\n      &lt;li *ngFor=\"#tab of tabs\" (click)=\"selectTab(tab)\" [class.active]=\"tab.active\"&gt;\r\n        &lt;a href=\"#\"&gt;&lt;\/a&gt;\r\n      &lt;\/li&gt;\r\n    &lt;\/ul&gt;\r\n    &lt;ng-content&gt;&lt;\/ng-content&gt;\r\n  `\r\n})\r\nexport class Tabs {\r\n    ...\r\n}<\/pre>\n<p>What we want, is to get a reference to all of the <code>&lt;tab&gt;<\/code> children that get projected into that section, so that we can act on their corresponding API (i.e. hiding\/showing them).<\/p>\n<p><strong><code>@ContentChildren<\/code> and <code>QueryList<\/code><\/strong><\/p>\n<p>We can do exactly this using the <code>@ContentChildren<\/code> decorator. You have to pass the decorator the type you want to get a reference to. In our example it would look like <code>@ContentChildren(Tab)<\/code>. As a result we will get a list of instances in the form of a <code>QueryList&lt;Tab&gt;<\/code>.<\/p>\n<blockquote><p><a href=\"https:\/\/twitter.com\/mgechev\">Minko Gechev<\/a> posted an awesome article explaining the <a href=\"http:\/\/blog.mgechev.com\/2016\/01\/23\/angular2-viewchildren-contentchildren-difference-viewproviders\/\"><strong>difference between @ContentChildren and @ViewChildren<\/strong> on his blog<\/a>. So I&#8217;m not going to replicate that here, simply check that article! <img decoding=\"async\" title=\":smiley:\" src=\"https:\/\/assets.github.com\/images\/icons\/emoji\/unicode\/1f603.png\" alt=\"\" width=\"20\" height=\"20\" align=\"absmiddle\" \/><\/p><\/blockquote>\n<p>A <code>QueryList&lt;T&gt;<\/code> is simply &#8220;an unmodifiable list of items that Angular keeps up to date when the state of the application changes&#8221; (see <a href=\"https:\/\/angular.io\/docs\/ts\/latest\/api\/core\/QueryList-class.html\">docs<\/a>).<\/p>\n<p>Hence, as a first step, we&#8217;re going to import the new constructs in our Tabs component.<\/p>\n<pre class=\" brush:php\">import { ContentChildren, QueryList } from 'angular2\/core';<\/pre>\n<p>Then, inside our class we can use it like<\/p>\n<pre class=\" brush:php\">import { Tab } from '.\/tab';\r\n...\r\nexport class Tabs {\r\n  @ContentChildren(Tab) tabs: QueryList&lt;Tab&gt;;\r\n}<\/pre>\n<p><strong><code>ngAfterContentInit<\/code> lifecycle hook<\/strong><\/p>\n<p>To access the list of <code>Tab<\/code> instances, we need to wait for them to be projected into our <code>Tabs<\/code> component. There&#8217;s a dedicated component lifecycle hook for that: <code>ngAfterContentInit<\/code>. This hook is called after the component content is initialized (more <a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/lifecycle-hooks.html\">on the official docs<\/a>).<\/p>\n<pre class=\" brush:php\">import { AfterContentInit } from 'angular2\/core';\r\n\r\n@Component({\r\n  selector: 'tabs',\r\n  ...\r\n})\r\nexport class Tabs implements AfterContentInit {\r\n\r\n  @ContentChildren(Tab) tabs: QueryList&lt;Tab&gt;;\r\n\r\n  \/\/ contentChildren are set\r\n  ngAfterContentInit() {\r\n    ...\r\n  }\r\n\r\n  ...\r\n}<\/pre>\n<p>Also note the <code>AfterContentInit<\/code> interface we&#8217;re importing. This is really just for better type checking with TypeScript. It doesn&#8217;t have any other effect, as TypeScript interfaces do not alter the transpiled JavaScript code, they disappear once you transpile.<\/p>\n<p>Within the <code>ngAfterContentInit<\/code> function we can now fetch all of our tabs and activate the first one if none is already set to be the active one.<\/p>\n<pre class=\" brush:php\">\/\/ contentChildren are set\r\nngAfterContentInit() {\r\n  \/\/ get all active tabs\r\n  let activeTabs = this.tabs.filter((tab)=&gt;tab.active);\r\n\r\n  \/\/ if there is no active tab set, activate the first\r\n  if(activeTabs.length === 0) {\r\n    this.selectTab(this.tabs.first);\r\n  }\r\n}<\/pre>\n<p>Similarly, whenever someone clicks on a tab header, we call the <code>selectTab(tab: Tab)<\/code> function which gets all of the tabs and deactivates all of them to finally set the clicked tab to active and thus visible.<\/p>\n<pre class=\" brush:php\">selectTab(tab: Tab){\r\n  \/\/ deactivate all tabs\r\n  this.tabs.toArray().forEach(tab =&gt; tab.active = false);\r\n\r\n  \/\/ activate the tab the user has clicked on.\r\n  tab.active = true;\r\n}<\/pre>\n<h2>The final solution<\/h2>\n<p>That&#8217;s it <img decoding=\"async\" title=\":+1:\" src=\"https:\/\/assets.github.com\/images\/icons\/emoji\/unicode\/1f44d.png\" alt=\"\" width=\"20\" height=\"20\" align=\"absmiddle\" \/>. You did it! Here&#8217;s the full code to play with:<\/p>\n<p><iframe src=\"https:\/\/embed.plnkr.co\/afhLA8wHw9LRnzwwTT3M\/\" width=\"100%\" height=\"400px\"><\/iframe><\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"http:\/\/juristr.com\/blog\/2016\/02\/learning-ng2-creating-tab-component\/\">Learning Angular 2: Creating a tabs component<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\">WCG partner<\/a> Juri Strumpflohner at the <a href=\"http:\/\/juristr.com\/blog\/\">Juri Strumpflohner&#8217;s TechBlog<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This is a follow-up article of\u00a0thoughtram&#8217;s excellent article on developing a tabs component with Angular 2, where we&#8217;re going to explore an alternative way of creating a tab component by learning about\u00a0@ContentChildren and\u00a0AfterContentInit. That said, definitely read thoughtram&#8217;s article on how to develop a tabs component in Angular 2 first. Then come back and continue &hellip;<\/p>\n","protected":false},"author":5,"featured_media":909,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-10679","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-angular-js"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Learning Angular 2: Creating a tabs component - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"This is a follow-up article of\u00a0thoughtram&#039;s excellent article on developing a tabs component with Angular 2, where we&#039;re going to explore an alternative\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Learning Angular 2: Creating a tabs component - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"This is a follow-up article of\u00a0thoughtram&#039;s excellent article on developing a tabs component with Angular 2, where we&#039;re going to explore an alternative\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-02-11T14:11:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Juri Strumpflohner\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/juristr\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Juri Strumpflohner\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/\"},\"author\":{\"name\":\"Juri Strumpflohner\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/33d3ee7edb105a80f1ff7199925b3060\"},\"headline\":\"Learning Angular 2: Creating a tabs component\",\"datePublished\":\"2016-02-11T14:11:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/\"},\"wordCount\":658,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"articleSection\":[\"Angular.js\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/\",\"name\":\"Learning Angular 2: Creating a tabs component - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"datePublished\":\"2016-02-11T14:11:13+00:00\",\"description\":\"This is a follow-up article of\u00a0thoughtram's excellent article on developing a tabs component with Angular 2, where we're going to explore an alternative\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Angular.js\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/angular-js\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Learning Angular 2: Creating a tabs component\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/33d3ee7edb105a80f1ff7199925b3060\",\"name\":\"Juri Strumpflohner\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/45338315375849845e4c4b30f52cb417221e2d9a7e688785e4dd2af0e624a260?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/45338315375849845e4c4b30f52cb417221e2d9a7e688785e4dd2af0e624a260?s=96&d=mm&r=g\",\"caption\":\"Juri Strumpflohner\"},\"description\":\"Juri Strumpflohner mainly operates in the web sector developing rich applications with HTML5 and JavaScript. Beside having a Java background and developing Android applications he currently works as a software architect in the e-government sector. When he\u2019s not coding or blogging about his newest discoveries, he is practicing Yoseikan Budo where he owns a 2nd DAN.\",\"sameAs\":[\"http:\/\/juristr.com\/blog\/\",\"http:\/\/linkedin.com\/in\/juristr\/\",\"https:\/\/x.com\/http:\/\/twitter.com\/juristr\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/juri-strumpflohner\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Learning Angular 2: Creating a tabs component - Web Code Geeks - 2026","description":"This is a follow-up article of\u00a0thoughtram's excellent article on developing a tabs component with Angular 2, where we're going to explore an alternative","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":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/","og_locale":"en_US","og_type":"article","og_title":"Learning Angular 2: Creating a tabs component - Web Code Geeks - 2026","og_description":"This is a follow-up article of\u00a0thoughtram's excellent article on developing a tabs component with Angular 2, where we're going to explore an alternative","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2016-02-11T14:11:13+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","type":"image\/jpeg"}],"author":"Juri Strumpflohner","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/juristr","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Juri Strumpflohner","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/"},"author":{"name":"Juri Strumpflohner","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/33d3ee7edb105a80f1ff7199925b3060"},"headline":"Learning Angular 2: Creating a tabs component","datePublished":"2016-02-11T14:11:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/"},"wordCount":658,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","articleSection":["Angular.js"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/","name":"Learning Angular 2: Creating a tabs component - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","datePublished":"2016-02-11T14:11:13+00:00","description":"This is a follow-up article of\u00a0thoughtram's excellent article on developing a tabs component with Angular 2, where we're going to explore an alternative","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/learning-angular-2-creating-tabs-component\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"Angular.js","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/angular-js\/"},{"@type":"ListItem","position":4,"name":"Learning Angular 2: Creating a tabs component"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/33d3ee7edb105a80f1ff7199925b3060","name":"Juri Strumpflohner","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/45338315375849845e4c4b30f52cb417221e2d9a7e688785e4dd2af0e624a260?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/45338315375849845e4c4b30f52cb417221e2d9a7e688785e4dd2af0e624a260?s=96&d=mm&r=g","caption":"Juri Strumpflohner"},"description":"Juri Strumpflohner mainly operates in the web sector developing rich applications with HTML5 and JavaScript. Beside having a Java background and developing Android applications he currently works as a software architect in the e-government sector. When he\u2019s not coding or blogging about his newest discoveries, he is practicing Yoseikan Budo where he owns a 2nd DAN.","sameAs":["http:\/\/juristr.com\/blog\/","http:\/\/linkedin.com\/in\/juristr\/","https:\/\/x.com\/http:\/\/twitter.com\/juristr"],"url":"https:\/\/www.webcodegeeks.com\/author\/juri-strumpflohner\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/10679","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=10679"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/10679\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/909"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=10679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=10679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=10679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}