Categories
Angular.js Vagrant

basic SPA (single page app) boilerplate for fast prototyping in angular

Creating this inside a Vagrant image (meaning there are extra steps to install the needed basic packages):

Creating the Vagrant workspace:

vagrant init ubuntu/trusty64;
vagrant up; vagrant ssh;
vi Vangrant # and then port forward 8080 to 8080 on the host

Creating the boilerplate:

mkdir myapp; cd myapp;
sudo apt-get update;
sudo apt-get install git;
sudo apt-get install npm;
sudo ln -s /usr/bin/nodejs /usr/bin/node;
npm init;
sudo npm install -g bower;
bower init;
touch main.js
touch index.html
git init
vi .gitignore
# include the following inside your .gitignore file:
mode_modules
bower_components
# back to the command line:
bower install --save angular
bower install --save ui-router

HTML / JS basic bootstrap

main.js

angular.module(“MyAppName”, [‘ui-router’])

.config(function ($stateProvider, $urlRouterProvider) {

});

index.html

<head>
<title>
My App Title
</title>
</head>
<body ng-app=MyAppName>
<h1>My App</h1>
<div ui-view></div>
<script src=bower_components/angular/angular.js></script>
<script src=bower_components/angular-ui-router/release/angular-ui-router.js></script>
<script src=main.js></script>
</body>

Quickly testing the page without setting up apache:

sudo npm install -g http-server

http-server