AngularJs ng-click 无效指令

AngularJs ng-click not working directive

当我点击我的 HTML img 时,ng-click 不起作用。我不明白为什么。此错误发生在 masonryPictureView.html

主页 - home.html

<ng-masonry>
  <ng-picture ng-items="projectdescription.pictures"></ng-picture>
</ng-masonry>

指令 ngPicture 模板 - masonryPictureView.html

<ul class="grille">
 <li ng-repeat="item in ngItems">
  <img ng-click="test()" src="{{item.img}}"/>      <------ NG-CLICK
 </li>
</ul>

home.html

中的指令
app.directive('ngMasonry', [function () {
    return {
        restrict: 'E',
        scope: {},
        transclude: true,
        templateUrl: "shared/masonry/masonryView.html",
        controller: function ($scope) {
            xxxxxxxxx......
        },
    }
}])

app.directive('ngPicture', ['$modal', '$log', function ($modal, $log) {
    return {
        require: "^ngMasonry",
        restrict: 'E',
        scope: {
            ngItems: '=ngItems'
        },
        templateUrl: "shared/masonry/masonryPictureView.html",
        link: function (scope, element, attrs, ngMasonryCtrl) {
            ngMasonryCtrl.setPictures(scope.ngItems);
        },
        controller: function ($scope) {
            $scope.test = function () < -- -- - function call in NG - CLICK {
                console.log("toto");
            }
        }
    }
}])

"projectdescription.pictures"从哪里来的,是数组吗?会不会是空的?在控制台中查找错误。我建议您对自定义指令或属性使用命名空间而不是 ng。我做了一个 plunker 演示,只要单击图像,就会触发测试方法。

您可能错过了 ngMasonry 指令中的 ng-transclude 占位符?

 template: '<div class="masonry"><ng-transclude></ng-transclude></div>',