angular中怎么样为动态新增的节点调用triggerHandler
方法?
我的节点是根据一个表动态生成的:
<a class="btn btn-default J_Local" href="javascript:void(0);" id="J_MapImg_{{my.sku_val_id}}" ng-click="uplod($event)"><span>本地上传</span></a>
点击事件如下:
$scope.uplod = function(obj){
supload.init({
button: ''+obj.currentTarget.id+'', uploaded: function (uploader, file, response) {
if (response.code == 1){
layer.msg(response.msg);
}
else {
$('#'+obj.currentTarget.id).siblings("p.preview").html("<img src='" + response.src + "' width='20' height='20'/>");
}
}
});
$('#'+obj.currentTarget.id+'').off("click");
}
但是动态生成的图片调用我的图片上传需要双击才能处罚,我想生成点击的时候让他自动trigger一下点击,该如何实现呢?
漂亮男人2017-05-15 17:10:56
如果是angularjs
,在里面混用jQuery是不对的
针对你的场景,无需动态插入html代码,掌握好以下知识点
angular.module('app', [])
.filter("trustUrl", ['$sce', function ($sce) {
return function (recordingUrl) {
return $sce.trustAsResourceUrl(recordingUrl);
};
}])
function($scope, $ajax) {
$scope.src = null;
$scope.upload = function() {
$ajax.post(...., function(response){
$scope.src = response.src;
$scope.$apply(); //通知更改了
}
}
}
<img src="{{src || 'http://...../upload.jpg'|trustUrl}}" ng-click="upload()">