AngularJs ng-click不使用fileupload字段

时间:2013-10-15 13:16:42

标签: javascript file angularjs angularjs-ng-click

我是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/

1 个答案:

答案 0 :(得分:1)

readUploadedImage('grPhoto', '{{ id }}')更改为readUploadedImage('grPhoto', id)。评估ng-click中的表达式。

Demo here