The Spotyngular Project: Part 4 – Template Syntax & Data Persistence

This is the fifth post of  “The Spotyngular Project” series of posts. Throughout this series, we are cloning spotify with AngularJS 2 to expose this framework’s benefits and tricks. We started our first post by talking about the basics of Angular JS 2, then we set up the environment, we got started with the demo and focused on the structure. Now we’ll go over the syntax  of AngularJS 2 templating feature.

AngularJS 2 has changed the syntax of its templating feature. The goal of the change is to give more meaning to the structures we define. Another important difference is that one-way bindings are prefered over two-way bindings between model and view, by default, thus enhancing performance.  

Let’s go over two Spotyngular’s components  that use the new syntax.

MusicStrip


The musicStrip component has a carousel that displays featured playlists with cards. Inside musicStrip there will be another component called Big Card that will display information about  the playlists.

We will begin with a simplest version and then we will start to fill in more complex behavior.

Simple Version


Let’s get started with the template. Here we have a placeholder for the title and then a row where all the spotyngular-browse-big-card elements will be laid out. In this first iteration we will only have one spotyngular-browse-big-card element but this will change pretty soon.

<style type="text/css">
...
</style>
 
<div id="musicStrip">
      <div class="section-divider">
             <div id="featuredPlaylistLabel">¡Dale play y disfruta!</div>
             <div class="section-auxiliary">
                     <button class="button button-icon-only disabled spoticon-chevron-left-16"></button>
                     <button class="button button-icon-only spoticon-chevron-right-16"></button>
               </div>
      </div>
      <div id="featuredPlaylists">
             <div class="row">
                   <div class="crsl-inner">
                          <spotyngular-browse-big-card
                                   [name]="'Hello'"
                                   [image]="'assets/featuredPlaylist/1.jpeg'"
                                   [desc]="'This is the description'">
                         </spotyngular-browse-big-card>
                     </div>
                 </div>
             </div>
         </div>

Read full post

2 Comments

Add a Comment

As it will appear on the website

Not displayed

Your website