Pass function method with parameter on angular directive

Posted: September 30, 2015 in web


$scope.clickFn = clickFn;

function clickFn(item) {


        .directive("swiperSlider", function () {
            return {
                restrict: 'E',
                replace: true,
                scope: {
                    list: '=',
                    className: '@',
                    clickFn: '&'
                templateUrl: 'template/swiper.html', 

Template (swiper.html)

<div ng-repeat="game in list" class="swiper-slide"><a ng-click="clickFn({item : game})" href><img width="100" ng-src="{{game.imagePath}}" /></a></div>

Template (index.html)

<swiper-slider  click-fn="clickFn(item)" class-name="semas" list="gameList"></swiper-slider>

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s