javascript - GetElementById equivalant in angular js -
<div> <input id="txt" type="text" placeholder="choose file" /> <input type="file" id="selectedfile" class="hidden" onchange="changetext(this, 'txt');" /> <span> <button type="button" onclick="document.getelementbyid('selectedfile').click();">browse</button> </span> </div>
i want on-click event in angular js. can tell?
i want on-click event in angular js. can tell? code in comment
okay, before might not have read question fully. have, , think you're looking for: https://plnkr.co/edit/pfju5b17qczwhkog4itn?p=preview
.controller('upload', ['$scope', function($scope) { this.input; this.browse = function() { this.input.click(); }; }]) .directive('fileupload', [function() { return { 'restrict':'e', 'controller':'upload', 'controlleras':'upload', 'templateurl': './upload.html', 'link':function($scope, $element, $attribute, upload) { upload.input = $element.find('input')[1]; } }; }]);
in link-function of directive injected input controller. controller fires click-event node, calling file-browser.
edit: not use input show file, show more generic listing of selected files, preview if possible. way have use first input :)
sorry not reading question better, hope helps.
Comments
Post a Comment