Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <script src=""></script>
<script src=""></script>
<script src="[email protected]/bundles/core.umd.js"></script>
<script src=""></script>
<script src="[email protected]/bundles/http.umd.js"></script>
<script src="[email protected]/bundles/common.umd.js"></script>
<script src="[email protected]/bundles/router.umd.js"></script>
<script src="[email protected]/bundles/compiler.umd.js"></script>
<script src="[email protected]/bundles/platform-browser.umd.js"></script>
<script src="[email protected]/bundles/platform-browser-dynamic.umd.js"></script>
<script src="[email protected]/bundles/forms.umd.js"></script>





                // app.js

const { Component, VERSION } = ng.core;
interface Item { id: number; name: string; color: string; }
  selector: 'my-app',
  template: `
<h3>Without trackBy :( we can't keep focus in the active input box when items (bullets) change as all items are recarated on collection change</h3>
    <li *ngFor="let item of items; let i = index">
      <strong [style.color]="item.color">{{}} | {{}}</strong>
      <input size="100%" [value]="values[i]" (input)="values[i] = $" >
<h3>With trackBy :) focus stays in the active input box even as items (bullets) change. Elements are re-rendered with standard change detection as angular can track elements with their id </h3>
  <li *ngFor="let itemTrackBy of items; trackBy: trackByFn; let i = index">
    <strong [style.color]="itemTrackBy.color" >{{}} | {{}}</strong>
    <input size="100%" [value]="values[i]" (input)="values[i] = $">
<a target="_blank" href="">Click Here to read full explanation</a>

class AppComponent  {

  values = ['', '', '']; // values bound to input boxes
  items: Item[]; // item to *ngFor without trackby
  itemsMock: Item[][]; // Array Mock item array to toggle between
  toggle: boolean;
  intervalTimer: any;

  constructor() {
    this.itemsMock = [
        {id: 1, name: 'One', color: 'red'},
        {id: 2, name: 'Two', color: 'blue'},
        {id: 3, name: 'Three', color: 'green'}
        {id: 1, name: 'Uno', color: 'blue'},
        {id: 2, name: 'Dos', color: 'green'},
        {id: 3, name: 'Tres', color: 'red'}

    this.items = this.itemsMock[0];

    this.toggle = false;
    this.intervalTimer = setInterval(() => {
    }, 5000);

  toggleItems() {
    this.toggle = !this.toggle;
    this.items = this.toggle ? this.itemsMock[1] : this.itemsMock[0];

  trackByFn(index, item ) {
    console.log( 'TrackBy:',, 'at index', index );
    return( );

  ngOnDestroy(): void {


// main.js
const { BrowserModule } = ng.platformBrowser;
const { NgModule } = ng.core;
const { CommonModule } = ng.common;
const { FormsModule } =  ng.forms

  imports: [
  declarations: [AppComponent],
  bootstrap: [AppComponent],
  providers: []
class AppModule {}

const { platformBrowserDynamic } = ng.platformBrowserDynamic; 

  .catch(err => console.error(err));