textAngular with ng-repeat of images

时间:2016-06-22 17:52:38

标签: angularjs textangular

Link to browser text editor
我有想在编辑器中添加的图像列表。我尝试了很多不同的东西,主要是添加图像的自定义工具栏。有没有办法在taOptions之外触发?我的最新尝试:

taRegisterTool('uploadImage', {
    iconclass: 'icon-picture-o',
    action: function(){
        var self = this;
        myPhotos.addImage = function() {
            if (myPhotos.selectedToAdd) self.$editor().wrapSelection('insertImage', myPhotos.selectedToAdd.url, true);
        }
    },
    onElementSelect: onElementSelect
});

myPhoto的工厂和功能在用户点击图片时调用addImage。用户打开图像列表时调用工具栏。这是第一次工作,但在第二个图像上单击它即使调用函数addImage也不添加图像。

编辑:我现在都在taRegisterTool里面重复。

taRegisterTool('allImages', {
    display: '<img ng-src="{{photo.url}}" class="nw-photofromgal" ng-repeat="photo in options" ng-click="action($event, photo)">',
    action: function(event, photo){
        console.log(event);
        console.log(photo);
        this.$editor().wrapSelection('insertImage', photo.url, true);
    },
    options: myPhotos.images
});

但是我仍然有添加照片的问题,ng-click不起作用,我得到了承诺作为参数。

1 个答案:

答案 0 :(得分:0)

我为图像添加了容器,并且ng-click得到修复。

taRegisterTool('allImages', {
    display: '<span><img ng-src="{{photo.url}}" class="nw-photofromgal" ng-repeat="photo in options" ng-click="action($event, photo)"></span>',
    action: function(event, photo){
        console.log(event);
        console.log(photo);
        this.$editor().wrapSelection('insertImage', photo.url, true);
    },
    options: myPhotos.images
});