我是AngularJS的新手,在上传图片之前尝试设置一些参数时,我一直停留在这个ng-click上。这是代码:
<div ng-controller="TestCtrl">
<div data-ng-click="readUploadedImage('grPhoto', '{{ id }}')">
<label class="changePhotoBtn" for="uploadBanner">Click Here</label>
<input style="display: none;" type="file" name="Upload a file" id="uploadBanner" />
</div>
</div>
var myApp = angular.module('myApp',[]);
function TestCtrl($scope) {
$scope.id = 1234;
$scope.readUploadedImage = function(parentClass, spid) {
alert(parentClass + ' ' + spid);
}
}
链接到小提琴:http://jsfiddle.net/CMJkg/2/
答案 0 :(得分:1)
将readUploadedImage('grPhoto', '{{ id }}')
更改为readUploadedImage('grPhoto', id)
。评估ng-click中的表达式。