を見つけたのでメモ。
<ul class="list-unstyled">
<li>...</li>
</ul>
これでリストのstyleが全て無効になる。
を見つけたのでメモ。
<ul class="list-unstyled">
<li>...</li>
</ul>
これでリストのstyleが全て無効になる。
例えば、記事とカテゴリがあって、カテゴリの数が多い順でカウント、ソートしたい場合のDQLは下記の通りになる。
$dql = "select
c.id,
c.name,
count(c.id) as cnt
from
HogeFugaBundle:Categories as c
join
c.articles as a
where
c.status = 1
group by
c.id
order by
cnt desc
";
DQLでのjoinのやり方は面白いね。
いちいちビューから$eventを渡して判定処理をかくのもダサいので、ディレクティブで定義されてるものを見つけてきた。
app.directive('ngEnter', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if(event.which === 13) {
scope.$apply(function (){
scope.$eval(attrs.ngEnter);
});
event.preventDefault();
}
});
};
});
ビューでこう使う。
<div>
<input type="text" ng-enter="doSomething()">
</div>
うん。これは便利。
HTML5モードと非HTML5モードの自動切り替えをAngular側にやってもらうためにも、aタグにリンクを埋め込むのではなく、$locationサービスを用いてルーティング変更を行うべき。
下記例。
コントローラー側に下記のようなメソッドを定義。
$scope.changeView = function(view){
$location.path(view);
}
ビュー側から下記のようにして移動先のロケーションパスを渡せばOK。
<button ng-click="changeView('/about')">ほげ</button>
といった感じ。
angualrのanimationは高速でクリックを繰り返したりすると、時々ng-animateクラスが削除され切らずにのこってしまい、表示がおかしくなる問題がある。
そこでアニメーションの終了を検知して、完了後自動でng-animateクラスを削除するように設定したらanimationの挙動を修正することが出来たのでメモ。
まずはanimation終了を検知するディレクティグを定義。
coreDirectives.directive('exShow', function($animate) {
return {
scope: {
'exShow': '=',
'afterShow': '&',
'afterHide': '&'
},
link: function(scope, element) {
scope.$watch('exShow', function(show, oldShow) {
if (show) {
$animate.removeClass(element, 'ng-hide', scope.afterShow);
}
if (!show) {
$animate.addClass(element, 'ng-hide', scope.afterHide);
}
});
}
}
});
次にビュー側で用意したトリガーに関数をバインドする。
<div class="top-search-section" ex-show="sarchSection" after-hide="doneAnimate('top-search-section')"></div>
として、コントローラーでこうする。
$scope.toggleSearchSection = function() {
$scope.sarchSection = $scope.sarchSection ? false : true;
}
$scope.doneAnimate = function(className) {
$('.' + className).removeClass('ng-animate')
}
アニメーション終了後、doneAnimateが動作して、指定された要素の「ng-animate」クラスが削除されるという流れ。
方法を調べたのでメモ。
input[type="radio"]{
-webkit-appearance: none;
width: 15px;
height: 15px;
border: 2px solid #aaa;
border-radius: 15px;
background: transparent;
opacity: 0.5;
width: 15px;
}
input[type="radio"]:checked{
background: #bbb;
opacity:1;
}
こんな感じにするとデザインを変更できる。
type=textのような入力フォームでタグ風に入力させることが出来るプラグイン。
http://ngmodules.org/modules/ngTagsInput
デモはこちら。
http://mbenford.github.io/ngTagsInput/demos.html
ドキュメントは下記。
http://mbenford.github.io/ngTagsInput/documentation
設定も豊富にあるし、これはめちゃくちゃ便利だわ。
テキストがだんだんとフェードアウトしていくような感じのデザイン。
http://css-tricks.com/text-fade-read-more/
これを参考に自分は白フェードアウトで実装してみた。
<div class="sidebar-box"> <p>長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文長文</p> <p class="read-more"><a href="#" class="button">もっと読む</a></p> </div>
.sidebar-box {
height: 120px;
position: relative;
overflow: hidden;
transition: height 0.8s ease;
-o-transition: height 0.8s ease;
-moz-transition: height 0.8s ease;
-webkit-transition: height 0.8s ease;
}
.sidebar-box .read-more {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
text-align: center;
margin: 0;
padding: 30px 0;
background-image: -webkit-linear-gradient(rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
background-image: -moz-linear-gradient(rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
background-image: -ms-linear-gradient(rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
background-image: -o-linear-gradient(rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
}