javascript - Storing a function expression inside a link function of an angularjs directive and use it via ng-click -


i have following angularjs directive , able use ng-click execute showmap() inside property-slider.html. missing?

(function() {     'use strict';      angular         .module('myapp')         .directive('propertyslider', propertyslider);      function propertyslider($timeout) {          return {             restrict: 'e',             templateurl: 'property-slider.html',             replace: true,             scope: {                 property: '=',                 photos: '='             },             link: function(scope, element) {                 $timeout(function(){                      var slider = element.flickity({                         cellalign: 'left',                         cellselector: '.gallery-cell',                         lazyload: true,                         wraparound: true,                         initialindex: 1                     });                      var showmap = function(){                         slider.flickity('select', 0);                     };                  },500);              }         };      }  })(); 

two issues....function needs assigned scope , don;t need create inside $timeout

link: function(scope, element) {       scope.showmap = function () {          element.flickity('select', 0);      };       $timeout(function () {            element.flickity({              cellalign: 'left',              cellselector: '.gallery-cell',              lazyload: true,              wraparound: true,              initialindex: 1          });       }, 500); } 

Comments