我試圖在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