Skip to content

Instantly share code, notes, and snippets.

@serabakpak
Last active September 16, 2016 15:26
Show Gist options
  • Save serabakpak/fb488ca51c25feafcd9a7176472250e9 to your computer and use it in GitHub Desktop.
Save serabakpak/fb488ca51c25feafcd9a7176472250e9 to your computer and use it in GitHub Desktop.
How to build an Angular app from scratch

How to build an Angular app from scratch

  1. First, we're going to assume that we already have a basic html boilerplate set up. Make sure that Angular is downloaded and linked in our index.html above our application script (usually named app.js).
<!-- VENDOR SCRIPTS -->
<script src="/vendor/angular/angular.min.js"></script>

<!-- APPLICATION SCRIPTS -->
<script src="/scripts/app.js"></script>
  1. To start with our Angular app, we define our app in app.js.
  var app = angular.module('appName', []);
  1. Then, we insert an ng-app directive into our index.html file to "direct" it to act as an Angular app.
<html lang="en" ng-app="appName">
  1. If we're using a controller, we also need to define it in app.js.
app.controller('PageController', PageController);
  1. Then, we declare its use in our index.html with the ng-controller directive.
<div ng-controller="PageController as pageCtrl">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment