我试图在ng-repeat内部上传和显示图像。AngularJS - 使用ng-repeat和jQuery上传和显示图像
我已经成功使用jQuery功能上传和显示图像不NG-重复:
<html>
<head>
<script src="jquery.js" type="text/javascript"></script>
</head>
<body>
<input type='file' />
<img id="myImg" ng-src="#" alt="your image" style="width:50px;height:50px"/>
</body>
</html>
...
<script>
$(function() {
$(":file").change(function() {
if (this.files && this.files[0]) {
var reader = new FileReader();
reader.onload = imageIsLoaded;
reader.readAsDataURL(this.files[0]);
}
});
});
function imageIsLoaded(e) {
$('#myImg').attr('src', e.target.result);
};
</script>
如果我改变的代码在里面NG-重复,jQuery函数dosent工作:
<div ng-repeat="step in stepsModel">
<input type='file' />
<img id="myImg" ng-src="#" alt="your image" style="width:50px;height:50px"/>
/div>
2个问题:
- 如何更改jQuery的功能角度的功能?
- 我如何使ng-reapeat处理jquery函数?
非常感谢
您必须提供一些代码和html ... – 2014-10-08 10:51:11
嗨,感谢您的更新,代码提供:) – 2014-10-08 11:13:11