2015-04-05 54 views
-2

如何更新用戶在文本區域中輸入的值的角度模型。 我必須動態地創建文本區域。如何更新角度JS的模型時,用戶按下OK鍵來給出值如何更新在textarea中輸入的動態創建的值的ng-model

function relation(event){ 

var display_area=document.getElementById("cart"); 
    // '<textarea maxlength="50" cols="18" rows="4" id="getRelation" style="border: solid 2px; "></textarea>' 
var relation_wrapper=document.createElement("div"); 
relation_wrapper.style.border="solid,3px"; 
relation_wrapper.style.borderColor="black"; 
relation_wrapper.style.width="100px"; 
relation_wrapper.style.height="500px"; 
relation_wrapper.style.backgroundColor="red"; 
var lineBreak=document.createElement("br"); 
var get_relation_button=document.createElement("button"); 
var button_text=document.createTextNode("OK"); 
relation_wrapper.appendChild(document.createElement("TEXTAREA")); 
relation_wrapper.appendChild(lineBreak); 
get_relation_button.appendChild(button_text); 
relation_wrapper.appendChild(get_relation_button); 
display_area.appendChild(relation_wrapper); } 

後,這將創建一個文本區域和一個按鈕 現在我想以更新的角度模型時,用戶按下按鈕的價值。 任何想法我怎麼能做到這一點

+0

是什麼型號?絕對沒有任何問題的角碼,我們不知道你是如何實現代碼 – charlietfl 2015-04-05 15:10:16

回答

0

您的代碼不夠清晰,但只是用$編譯服務,其餘的將被處理重新編譯動態內容的角度,如:

$compile(angular.element(display_area).html())($scope); 
+0

其實我很安靜新角度...有沒有什麼辦法,我可以得到一個泡沫彈出通過我可以得到的文字和使用角度拖放來調用它。 – Affan 2015-04-06 10:35:31

相關問題