It’s been a while since I’ve updated this blog, but that does not mean that I have not been working! I recently signed up for a subscription to Code School, and knocking out courses left and right. Every path that I finish (or when I feel a topic warrants it), I plan to create an example with what I learned. I recently finished the HTML/CSS path, and applied that knowledge toward a website for the Archer show’s “Figgis Detective Agency”.

What I Learned, and What Is Next

Many topics were covered in the HTML/CSS path, it was a nice mix of refreshment and new topics. Covered topics included:

  • HTML5
  • CSS3
  • SVG
  • Mobile/Responsive/Fluid Designs
  • Animations with CSS
  • Bootstrap
  • Color Schemes
  • And others

I tried to incorporate most of the topics into the created example I talk about above. Next up, I am tackling the Javascript path which has been slow going, and much harder than the previous path. I am just about finished with the basics, and I look forward to refreshing on my jQuery skills. Past that, the path includes courses on Ember, Backbone, Angular, and more. I hope to use each of those in their own example sites so I can build diverse portfolio.

Angular Docs is a great resource to reference when building an app with the framework. With Angular 2, it is built upon Typescript, which may be new to some people. Typescript is a superset of Javascript, which introduces classes to the mix. Furthermore, Angular 2 also uses AtScript, which extendes the Typescript language. AtScript uses the notation ‘@’, which is clearly the idea behind the name. Let’s look at how Angular 2 components utilize this.

The Structure of A Component


import { Component } from 'angular2/angular2';

@Component({
    selector: 'my-app',
    template: '
Hello World
' }) class MyClass { //Code Goes Here }

Import the Component

There are 3 basic parts to the component. First is the import statement, which pulls the ‘Component’ from the Angular2 directory ‘angular2/angular2’ into the app file you are working on. Just as your index.html page needs to know where to find your stylesheet or script, this is an AtScript call to the file you need.

@Component

The above code is where the information about the Component are built. selector: 'my-app' is saying, “I would like my Component to be referenced in the HTML as <my-app></my-app>. You can name this whatever you please, but it is always good practice to use a descriptive name to be able to tell it apart.

template: '<div>Hello World</div>' is defining what you would like to appear when you reference <my-app></my-app> on the page. Other selectors can be referenced in the template, but that can be covered at a later time. For now, lets stick with the basics. If you feel the template should live outside of the scripting portion, you can also use templateUrl: 'path/file.html' to reference an external template.

You may also see the template broken away from the @Component and placed in a @View instead.

Class

In the last portion is the class, and it is where the magic happens. This is where you will store variables and functions to use in your Component, utilizing Typescript syntax.

That’s It?

No, not quite. Save this file in your site’s directory as a Typescript file. Most examples I have seen will place them into a new folder, like app/myfile.ts. Now, we have to bootstrap the Component so the page will load it. You can either put this in the file you just created, but I prefer to separate it into a boot.ts file in the same directory. Again, you will need to import your app if you put it in a separate file, along with bootstrap as well. For the example above, we would make our boot file like so:


import {bootstrap} from 'angular2/platform/browser';
import {MyClass}   from './myfile';
bootstrap(MyClass);

One Last Thing


      System.config({
        transpiler: 'typescript',
        typescriptOptions: { emitDecoratorMetadata: true },
        packages: {'app': {defaultExtension: 'ts'}}
      });
      System.import('app/myfile')
            .then(null, console.error.bind(console));

The SystemJS will need configured in your index.html file, so that it points to your app file you just created. Notice the import statement toward the bottom, it is pointing to `app/myfile.ts’ The Typescript will compile down to Javascript (using a compiler, its not automatic) and …

Now you can enjoy your freshly created app

Hey there! I’ve added a ‘Projects’ tab so you can see what I accomplished. Spoiler alert, not much :( . So far, I have 3 basic Angular 2 examples, but I hope to get more done soon. There are many frameworks and libraries I want to play around with, it is hard to choose one and stick with it. In the future I hope to do more with AJAX, various API’s, React.js, Wordpress, and maybe some AngularJS.

What Are Those?

So, I got my first post in, and I couldn’t help but write down the things I’ve learned in the past couple hours since. Just as a friendly reminder to myself (or anyone who stumbles upon this blog), what I have found out in this short time.

Site Folder

Its noted in the structure as _site. You may have noticed it after running bundle exec jekyll serve, which I wrote about in the first post. This is where the static content is being compiled together after a file is saved while that command is running. If it is not running currently, it will compile on the next run.

Posts Folder

This one is where all the blog posts, such as this one, are placed to be read into the site. From the video’s I have seen, it does not look like this is a default Jekyll folder, so maybe it came with the template I am using?

_posts also has requirements to follow to make the blog work. Files must be saved in the format YYYY-MM-DD-title.extension. I am using Markdown to write these posts, so an example would be 2016-02-25-post-title.md.

Side Note

I had issues with this post as well, and my h2 tags were not being rendered. Make sure the #’s do not have any spaces to the left. They need to be the very first characters of that line.

I Have A Lot To Learn

This is the first post of hopefully many to come. There’s a lot of new aspects of Web Development being introduced, even with this post alone. Markdown seems to be an easy language to use, but this is the first time I’ve used it. Jekyll is also new to my skillset, and seems easier than WordPress so far. Even GitHub is relatively new to me, and my account is not new at all. I’ve sat on this account for a couple years now, with no contributions to show for it.

Even This Post Is A Learning Experience

Hell, just figuring out how to make a header properly took a little research. I wasn’t putting empty lines in between, so it just rendered as plain text. Not to mention all the issues I had trying to setup everything. FYI to any other beginners out there, bundle exec jekyll serve got around the missing jekyll-paginate error.