Skip to content

Instantly share code, notes, and snippets.

angular.module("alert-directive", [])
.directive('alert', function () {
return {
restrict: 'EA', // support to be used as an element or an attribute
replace: true, // tells the compiler to replace the original directive's element with the template given by the template field
template: '<div class="alert alert-{{type || \'info\'}}">' +
'<button type="button" class="close" ng-click="close()">&times;</button>' +
'<div ng-transclude></div>' + // the ng-transclude directive gets the transcluded elements and appends them to the element in the template on which it appears
'</div>',
angular.module('app', ['alert-directive'])
.controller('AlertController', function ($scope) {
$scope.alerts = [
{ type: 'error', msg: 'Oh snap! Something went wrong.' },
{ type: 'success', msg: 'Well done! It worked out in the end.' }
];
$scope.addAlert = function () {
$scope.alerts.push({msg: "Watch out - another alert!"});
@xuyuanme
xuyuanme / nginx.sh
Created February 26, 2011 01:42
Install Nginx and config Google ghs proxy
#!/bin/sh
# Install Nginx and config Google ghs proxy, tested on Amazon EC2 Linux
# You need first to add a domain A record point ghs to the server which runs Nginx
# and then alias sub-domain to ghs.your_domain_name
# Author: Yuan XU
# Version: 0.1
# URL: blog.xuyuan.me
if [ -z $1 ]; then
echo "Usage: nginx.sh [domain_name]"
@xuyuanme
xuyuanme / nginx.conf
Created February 26, 2011 00:34
Nginx config file for Google ghs proxy
#######################################################################
#
# This is the main Nginx configuration file.
#
# More information about the configuration options is available on
# * the English wiki - http://wiki.nginx.org/Main
# * the Russian documentation - http://sysoev.ru/nginx/
#
#######################################################################