angularjs - Angular calling function within Directive -


  .directive('optionfoundaddressclickabledisplay', function(search,$state,service,$log) {     'use strict';     return {       replace: true,       restrict: 'ae',       template: '<ul class="dropdown-menu apartment-group" ng-show="barclickable"><li><a href ng-click="searchmatch()"><span class="gr-arrow pull-right"></span>' +       '<div class="result-text ng-binding"><img src="images/map-pin.png"  class="map-pin" alt=""/>{{ buildingname }}</div> </a>' +       '</li></ul>',       link: function(scope, element, attrs) {         scope.buildingname = search.result.buildingaddress;         scope.barclickable = (search.result.matchednua || search.result.matchedid !== null) ? true : false;         scope.searchmatch = function(){           $log.warn("gets here");         };       }     };   }) 

can't seem hit function within directive ng-click - searchmatch(). need declare function in directive in different way ?

define in directive controller,

ex:

.directive('optionfoundaddressclickabledisplay', function(search,$state,service,$log) { 'use strict';     return {         replace: true,         restrict: 'ae',         template: '<ul class="dropdown-menu apartment-group" ng-show="barclickable"><li><a href ng-click="searchmatch()"><span class="gr-arrow pull-right"></span>' +   '<div class="result-text ng-binding"><img src="images/map-pin.png"  class="map-pin" alt=""/>{{ buildingname }}</div> </a>' +   '</li></ul>',          link: function(scope, element, attrs) {                    scope.buildingname = search.result.buildingaddress;                    scope.barclickable = (search.result.matchednua || search.result.matchedid !== null) ? true : false;          },           controller : function($scope) {              $scope.searchmatch = function(){              $log.warn("gets here");         };     }   }; }) 

here demo plunker


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -