AngularJS中自定义指令的访问功能

时间:2015-04-24 12:27:27

标签: javascript angularjs angularjs-directive

这是我的HTML。 genericsearch是一个指令:

<genericsearch  search-text="organisationSearchEvent"></genericsearch>

我试图打电话给organisationSearchEvent但是没有被叫。我该如何解决这个问题?

我的指示

.directive('genericsearch', [function () {
 return {
  restrict: 'E',
  replace: true,
  scope: {
      objectType : '=',
      searchText: '=',

  },
  link:function(scope,elem,attrs) {    
      scope.myParam = 'tei_org';
  },
  controller: [
      '$scope',
      '$element',
      '$rootScope',
      'SearchOrg',
      'MapOrgs',
      '$routeParams',
      'DelOrgs',
      'GetTemplateGroups',
      'FetchOrgs',
      function($scope,$element,$rootScope,SearchOrg,MapOrgs,$routeParams,DelOrgs,GetTemplateGroups,FetchOrgs){
     $scope.organisationSearchEvent=  function(organisationSearchEvent,filter) {
              console.log('orglist'+JSON.stringify($scope.myParam));
              console.warn('text'+JSON.stringify($scope.text));
              SearchOrg().fetch({'filter':filter, 'searchType':'tei_org'}).$promise.then(

                function(value){
                    $scope.orgList = value.data;  
                },
                function(err){

              });
          });

          $scope.getOrgs = function(data, event) {
              if(event.keyCode != 13){
                  //$scope.Participants(data);
                  $scope.organisationSearchEvent(data);
              }
          }

          // console.log('orglist'+JSON.stringify($scope.orgList));
      }
],
templateUrl : TAPPLENT_CONFIG.HTML_ENDPOINT[0]+'home/search.html'
}}])

0 个答案:

没有答案