Angularjs Custom Directive ng-click not working

前端 未结 2 1903
予麋鹿
予麋鹿 2021-02-20 04:21

i\'ve created a custom directive in angularjs:

directives.directive(\'myTop\',function($compile) {
return {
    restrict: \'E\',
    templateUrl: \'views/header.         


        
2条回答
  •  孤独总比滥情好
    2021-02-20 05:11

    Either use link as answered by @Ashesh or just simply add scope. If you set scope false you will not have isolated scope and click will work on directive.

    directives.directive('myTop',function($compile) {
    return {
       restrict: 'EA',
       scope: false,
       templateUrl: 'views/header.html',
      }
    })
    

提交回复
热议问题