2017-02-16 46 views
0

我想從組件控制器訪問fileInput,textInput的值而不使用ng-model。但我越來越沒有定義。通過從組件控制器訪問ID

<form name="uploadForm"> 
<div layout-gt-sm="row"> 
    <input id="fileInput" type="file" class="ng-hide"> 
    <md-input-container md-no-float class="md-block"> 
     <input id="textInput" type="text" placeholder="No file chosen" ng-readonly="true" required current-dir="$ctrl.currentDir"> 
    </md-input-container> 
    <md-button id="uploadButton" class="md-raised md-primary">Choose file</md-button> 
    <md-button id="saveButton" class="md-raised md-primary" ng-click="$ctrl.uploadVideoFile($event)" >Upload</md-button> 
</div> 
</form> 



    var input = $(element[0].querySelector('#fileInput')); 
    var button = $(element[0].querySelector('#uploadButton')); 
    var textInput = $(element[0].querySelector('#textInput')); 
+1

你嘗試過用angular.element()? –

+0

是的,我做到了。我正在嘗試使用ng-model – user6934713

+1

? ..你不需要ng模型..只是嘗試像à:var input = angular.element('#fileInput')); –

回答

1

試試這個

var input = angular.element('#fileInput');