Component doing http call for Page not loading content properly

I’ve pasted the code below. The deal is… I’m trying to asynchronously get some data from my API and load this component into my page once that data is retrieved. While it’s getting the data… the ‘loading’ in <song>loading...</song> is not displaying properly. I truly have no idea what I’m doing. I’ve been following the tutorials for Angular 2 to try to hack this project together. Any kind of feedback welcome!


<ion-navbar *navbar dark>
  <button menuToggle (click)="stopSong()">
    <ion-icon name="menu"></ion-icon>
  <!-- <ion-title>k-bop!</ion-title> -->

<ion-content class="home">

      <button primary clear item-left>
        <ion-icon name="heart"></ion-icon>
        <div>12 Likes</div>
      <button primary clear item-left>
        <ion-icon name="text"></ion-icon>
        <div>4 Comments</div>

  <button full *ngIf="!loggedIn()" (click)="login()">Login</button>



import {Page, NavController} from 'ionic-framework/ionic';
import {LoginService} from '../../login.service';
import {SongService} from '../../song.service';
import {Song} from '../../song'
import {HTTP_PROVIDERS}    from 'angular2/http';
import {SongComponent} from '../../song.component';

  templateUrl: 'build/pages/home/home.html',
  providers: [LoginService, HTTP_PROVIDERS, SongService]
export class HomePage {

  constructor(private _loginService: LoginService) { }

  loggedIn() {
    return this._loginService.loggedIn();

  login() {


import {Component, OnInit} from 'angular2/core';
import {IONIC_DIRECTIVES} from 'ionic-framework/ionic';
import {Song}              from './song';
import {SongService}       from './song.service';
import {PlaylistService} from './playlist.service';

  selector: 'song',
  template: `
  <div *ngIf="currentSong">
    <ion-avatar item-right>
      <ion-icon name="md-musical-note" item-right></ion-icon>
    <h2>{{ currentSong.artist }}</h2>

  <img [src]="currentSong.image_large" (click)="toggleSong()">

    <h4>{{ currentSong.title }}</h4>

  <ion-item class="deciders">
      <button dark clear round item-left (click)="decide(false)">
        <ion-icon name="sad"></ion-icon>
      <button dark clear round item-right (click)="decide(true)">
        <ion-icon name="happy"></ion-icon>
  directives: [IONIC_DIRECTIVES]
  // styles: ['.error {color:red;}'],
export class SongComponent {
  songs: Song[];
  currentSong: Song;
  audio: any;
  paused: boolean;

  constructor (private _songService: SongService, private _playlistService: PlaylistService) {
    // this.currentSong = {artist: "Loading", title: "Loading Song", preview: "", image_large: "", spotify_url: ""};
    console.log('calling api')

  getSongs() {
         songs => { this.songs = songs; this.currentSong = this.songs[0]; console.log(this.currentSong)},
         error => console.log(<any>error));

  toggleSong() {
    if (this.paused) {
      this.paused = false
    } else {
      this.paused = true

  stopSong() {
    if ( {;

  startSong() {
    if ( {;

  playSong() {
    return new Promise((resolve, reject) => { = new Audio(this.currentSong.preview); = true; = reject; = resolve;

  decide(choice) {
    if (choice) {

    let randomNumber = Math.round(Math.random() * (this.songs.length - 1));
    this.currentSong = this.songs[randomNumber];

    this.playSong().then((success) => {
      console.log("Preview complete")
    }, (error) => {
      alert("Something has gone wrong");


import {Song} from './song';
import {SONGS} from './mock-songs';
import {Injectable} from 'angular2/core';
import {Http, Response} from 'angular2/http';
import {Observable}     from 'rxjs/Observable';
import 'rxjs/Rx';

export class SongService {
  private _songsUrl = "";
  // private _songsUrl = "app/songs"

  constructor(private http: Http) { }

  getSongs () {
    return this.http.get(this._songsUrl)
      .map(res => <Song[]> res.json())
      .do(data => console.log(data))

  private handleError (error: Response) {
    // in a real world app, we may send the error to some remote logging infrastructure
    // instead of just logging it to the console
    return Observable.throw(error.json().error || 'Server error');


export interface Song {
  title: string;
  artist: string;
  preview: string;
  image_large: string;
  spotify_url: string;

I just took the http part out unto a seperate plunkr and it is working