hover image effect with angularjs directive -



hover image effect with angularjs directive -

i seek utilize client jquery.hover create background effect when hovering news item. set in directive

index.html

<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" ng-app="myapp"> <head> <title></title> <base href="/"> <script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.js"></script> <script src="jquery.hoverdir.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js"></script> <style> .da-thumbs { list-style: none; position: relative; margin: 30px auto; padding: 0; } .da-thumbs li { float: left; position: relative; width: 320px; height: 320px; } .da-thumbs li { overflow: hidden; color: #fff; display: block; position: relative; } .da-thumbs li img { width: 320px; height: 320px; } .da-thumbs li div { position: absolute; width: 100%; height: 100%; padding: 20px; } .new-highlight div { font-size: 1.8em; font-weight: 700; text-shadow: 1px 2px #cc731b; padding-top: 40px; text-align: center; letter-spacing: -1px; background: url(images/opc80.png) repeat; } .event-hot div { background: rgba(0, 0, 0, 0.5) } .event-hot h4 { text-transform: uppercase; margin-bottom: 20px; font-weight: 700; text-shadow: 1px 1px rgba(0, 0, 0, 0.5); } </style> <script> var app = angular.module('myapp', []); app.controller('homectrl', function ($scope) { $scope.featuredevents = { data: [{ title: 'title 1', short: 'short 1', imageurl: 'http://www.vincomshoppingmall.com/vi-vn/images/thumb.axd?id=1153' }, { title: 'title 2', short: 'short 2', imageurl: 'http://www.vincomshoppingmall.com/vi-vn/images/thumb.axd?id=1152' }] }; }); app.directive('hotevent', ['$document', function ($document) { homecoming { restrict: 'ea', templateurl: 'events.html', link: function ($scope, ielement, attrs) { //attrs references attributes on directive element in html angular.element(document).ready(function () { var dathumb = $(ielement).find('.da-thumbs > li a'); //$scope.$evalasync(function () { console.log('?: ' + dathumb.length); dathumb.each(function () { $(this).hoverdir(); }); //}); }); } } } ]); </script> </head> <body ng-controller="homectrl"> <div hot-event></div> </body> </html>

events.html

<ul class="row da-thumbs event-hot"> <li ng-repeat="news in featuredevents.data"> <a href="/"> <img src="{{news.imageurl}}" /> <div> <h4>{{news.title}}</h4> <p> {{news.short}} </p> </div> </a> </li>

on visual studio, works doesn't show effect after ctrl-f5. (chrome got disabled caching)

plnker link here , don't know why doesn't show on plunker either.

angularjs angularjs-directive

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -