Pass function directive angularjs with params

Posted: October 9, 2015 in web

template

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

directive template: important thing is the {item:value} item should match the function param name.

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

directive


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

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s