Skip to content

Instantly share code, notes, and snippets.

@freizl
Last active August 29, 2015 13:56
Show Gist options
  • Save freizl/9113654 to your computer and use it in GitHub Desktop.
Save freizl/9113654 to your computer and use it in GitHub Desktop.
Cant use directive twice
<!doctype html>
<html ng-app="yi">
<head>
<!-- script src="../angular-1.2.9.js"></script -->
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<style type="text/css">
.yang-yao {
background-color: red;
width: 100px;
height: 45px;
}
.yang-yao.small {
width: 20px;
height: 8px;
}
.gua {
border: 1px solid blue;
}
.gua .yang,
.gua .yin {
display: block;
}
.gua.large .yang,
.gua.large .yin {
margin-top: 10px;
height: 30px;
width: 160px;
}
.gua.small .yang,
.gua.small .yin {
margin-top: 3px;
height: 3px;
width: 30px;
}
.gua .yang {
background-color: #FF1100;
}
/* SMARTER WAY */
.gua .yin {
border-left: 75px #000 solid;
border-right: 75px #000 solid;
width: 10px !important;
}
.gua .yin2 {
/* FIXME: HOW to support IE < 10 */
background-image: -ms-linear-gradient(left, #000000 0%, #000000 46%, #FFFFFF 46%, #FFFFFF 54%, #000000 54%, #000000 100%);
background-image: -o-linear-gradient(left, #000000 0%, #000000 46%, #FFFFFF 46%, #FFFFFF 54%, #000000 54%, #000000 100%);
background-image: -moz-linear-gradient(left, #000000 0%, #000000 46%, #FFFFFF 46%, #FFFFFF 54%, #000000 54%, #000000 100%);
background-image: -webkit-linear-gradient(left, #000000 0%, #000000 46%, #FFFFFF 46%, #FFFFFF 54%, #000000 54%, #000000 100%);
background-image: linear-gradient(left, #FFFFFF 0%, #FFFFFF 50%, #000000 50%, #000000 100%);
}
</style>
<script type="text/ng-template" id="gua.html">
<section class="gua {{guaSize}}">
<span ng-repeat="item in items" key={{item.v}} class={{item.clazz}} > </span>
</section>
</script>
</head>
<body>
<yi-gua gua-size="large" key="111000" />
<hr />
<yi-gua gua-size="small" key="000111" />
<script type="text/javascript">
angular.module("yi", [])
.directive('yiGua', ['$compile', function($compile) {
return {
replace: true,
restrict:'E',
scope: {},
link: function(scope, element, attrs){
scope.key = attrs.key;
scope.guaSize = attrs['guaSize'];
console.log(attrs)
var xs = attrs.key ? attrs.key.split('') : [];
scope.items = xs.map(function (x) { return { v: parseInt(x, 10), clazz : (x === '1' ? 'yang' : 'yin') }; });
},
templateUrl: 'gua.html'
};
}])
;
</script>
</body>
</html>
@freizl
Copy link
Author

freizl commented Feb 21, 2014

Custom directive need to be explicitly closed.

<yi-gua gua-size="large" key="111000" ></yi-gua>

@freizl
Copy link
Author

freizl commented Feb 25, 2014

RewriteEngine on
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [L]

ExpiresActive On
ExpiresDefault "access plus 1 month"
ExpiresByType text/html "modification plus 2 days"
ExpiresByType text/css "access plus 26 weeks"
ExpiresByType image/gif "access plus 26 weeks"
ExpiresByType image/jpg "access plus 26 weeks"
ExpiresByType image/jpeg "access plus 26 weeks"
ExpiresByType image/png "access plus 26 weeks"
ExpiresByType image/bmp "access plus 26 weeks"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment