我想獲取用戶更新的值並將其粘貼到模態的文本區域中。但它返回undefined
。我無法理清原因。 這是代碼。如何獲取模態定義的角度值
$scope.details=[];
$scope.addDetails=function() {
$scope.details.push({
Title: $scope.Details_Title,
meta_chars: $scope.Details_metaChars,
version: $scope.Details_version,
Auth_name: $scope.Details_AuthName,
copyRights: $scope.Details_copyRights
});
}
$scope.genrate_HTML=function() {
document.getElementById("createdHTML").value=$scope.details;
}
下面是HTML
<div ng-controller="GenrateHTML">//name of the controller
<button ng-click="genrate_HTML();toggleModal()" class="btn btn-success btn-sm" id="btnGenerateHTML">Generate HTML </button>
<modal title="Enter Document Details" visible="showModal" >
<!--<div ng-controller="GenrateHTML">-->
<textarea contenteditable="true" type="text" id="createdHTML" name="HTML_content" placeholder="Title" style="margin-top:10px" class="form-control" ></textarea>
<button class="btn btn-success btn-sm" data-dismiss="modal" style="margin-top:10px;margin-left:520px;" ng-click=" savefile()">Save</button>
</modal>
</div>
toggleModal()
顯示模式,savefile()
節省本地計算機上的文件,他們正在工作的罰款。但我不知道爲什麼textarea返回undefined
。我試過pop()
,value()
,它返回undefined
。
有你沒有設置NG-模型的一個原因textarea然後在你的generate_HTML函數中使用這個值? – Scott
我需要顯示模型$ scope.details的值,用戶已使用此文本區域中的另一個函數更新。所以我認爲ng-model並不是必需的,另外我會在後期將不同模型的值放入。 – Affan
我很困惑你在這裏試圖做什麼......你似乎試圖將一個'