Skip to content

Instantly share code, notes, and snippets.

// controllers
function deviceListController($scope)
{
$scope.devices = [
{name: "iphone", assetTag:"a23456", owner:"dev", desc:"iOS4.2"},
{name: "loaner-laptop-1", assetTag:"a13936", owner:"dev", desc:""},
{name: "loaner-laptop-3", assetTag:"a43056", owner:"qa", desc:""},
{name: "android", assetTag:"a33756", owner:"dev", desc:"android2.4"},
{name: "galaxy tab", assetTag:"a53356", owner:"dev", desc:"android"},
@sunkay
sunkay / deviceService.js
Created April 21, 2013 20:42
Angular Module
// create a module to support getting and managing the device list
var deviceModule = angular.module('DeviceModule', []);
// setup the service factory to create our items. Should retrieve from the server side db
deviceModule.factory('Devices', function(){
var items = {};
items.query = function(){
return [
{id:0, name: "iphone", assetTag:"a23456", owner:"dev", desc:"iOS4.2"},
@sunkay
sunkay / main.html
Created April 21, 2013 20:50
main.html which using angular ng-view
<html ng-app="cotd">
<head>
<title>Check out your device</title>
<link rel="stylesheet" href="../bootstrap/css/bootstrap.css">
</head>
<body>
<h2>List of Devices</h2>
<div ng-view></div>
<div ng-controller="deviceListController">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Asset Tag</th>
<th>Owner</th>
<th>Description</th>
</tr>
</thead>
@sunkay
sunkay / cotd.js
Created April 21, 2013 20:54
main controller which provides the routes & models
// Global app module listing all its dependencies
var cotdServices = angular.module('cotd', ['DeviceModule']);
// setup mappings routes and templates
function cotdRouteConfig($routeProvider){
$routeProvider.
when('/', {
controller: deviceListController,
templateUrl: 'listDevices.html'
}).
@sunkay
sunkay / nginx
Last active December 16, 2015 11:59
nginx commands
Mac:cotd$ sudo nginx
Mac:cotd$ ps -ef|grep nginx
0 22354 1 0 5:10PM ?? 0:00.00 nginx: master process nginx
-2 22355 22354 0 5:10PM ?? 0:00.00 nginx: worker process
502 22357 19529 0 5:10PM ttys000 0:00.00 grep nginx
STOPPING NGINX
Mac:cotd$ sudo nginx -s stop
Mac:cotd$ ps -ef|grep nginx
@sunkay
sunkay / gist:5438504
Created April 22, 2013 21:00
shows how to use ng-show & ng-hide
<div ng-controller="deviceListController">
<div ng-hide="devices.length">
You have no devices setup.
<a href="#/admin/add-new">Would you like to add?</a>
</div>
@sunkay
sunkay / gist:5446739
Created April 23, 2013 19:40
Basic Angular Form partial
<div ng-controller="addDeviceController">
<form novalidate name="addDevice" class="form-horizontal">
<div class="control-group">
<label class="control-label">Name</label>
<div class="controls">
<input type="text" id="name" placeholder="Enter Name">
</div>
</div>
<div class="control-group">
<label class="control-label">Asset Tag</label>
@sunkay
sunkay / gist:5457136
Created April 25, 2013 02:43
Form with ng-model hooks
<div ng-controller="addDeviceController">
<form novalidate name="addDevice" class="form-horizontal">
<div class="control-group">
<label class="control-label">Name</label>
<div class="controls">
<input type="text" id="name" ng-model="device.name" required placeholder="Enter Name">
</div>
</div>
<div class="control-group">
<label class="control-label">Asset Tag</label>
@sunkay
sunkay / gist:5457171
Created April 25, 2013 02:50
Sharing data using Angular Services
// create a module to support getting and managing the device list
var deviceModule = angular.module('DeviceModule', []);
// setup the service factory to create our items. Should retrieve from the server side db
deviceModule.factory('Devices', function(){
var items = {};
items.data = [
{id:0, name: "iphone", assetTag:"a23456", owner:"dev", desc:"iOS4.2"},
{id:1, name: "loaner-laptop-1", assetTag:"a13936", owner:"dev", desc:""},