gpt4 book ai didi

javascript - 如何从 ng-repeat 中保存元素?

转载 作者:行者123 更新时间:2023-12-03 08:57:09 26 4
gpt4 key购买 nike

我正在使用 ng-repeat 显示元素,并且我想选择其中一个元素,然后在另一个 div 页面或其他页面中显示所选元素。

    <div ng-show="newsignature" id="newsignature">
<div class="ng-cloak">
<div ng-click="showcreateform()" ng-hide="createsignature" class="ncontact" ng-repeat="template in signaturetemplates">
<h2>{{template.name}}</h2>
<div class="tdescrip" data-ng-bind-html="template.templatesample"></div>
<br>
</div>
</div>
</div>

我想要保留的元素是名称和 html,但我不知道该怎么做。

当我选择一个元素时,我显示一个带有输入字段的表单,在表单的顶部我有一个预览按钮,我单击时的想法是显示使用中给出的信息选择的模板的预览输入。我无法在第一步中获取或保留模板(是 HTML)以在预览中显示。

<div ng-show="createsignature">
<h2 ng-model="newSignature.name" placeholder="Name this Signature" contenteditable="true">Name this signature </h2>
<span id="cancel" class="pull-right cancel cancels" ng-click="createsignature=false"><button>CANCEL</button></span>
<span ng-click="showpreview(); createsignature=false; newsignature=false;"id="save" class="pull-right cancel" ><button>PREVIEW</button></span>
<div class="pull-left">
<span id="addsi" ng-click="createsignature=false;" class="pull-left"><img src="images/b-a-c-k-btn.png"><h2> New Signature</h2></span>
</div>
<table class="spacing-table table ">
<tr>
<td><input class="fill" ng-model="echo_Name" contentEditable="true" placeholder="Name"></input></td>
<td></td>
<td></td>
</tr>
<tr>
<td><input class="fill" ng-model="echo_Title" contentEditable="true" placeholder="Title"></input></td>
<td></td>
<td></td>
</tr>
<tr>
<td><input class="fill" ng-model="echo_Department" contentEditable="true" placeholder="Department"></input></td>
<td></td>
<td></td>
</tr>
<tr>
<td><input class="fill" ng-model="echo_Company" contentEditable="true" placeholder="Company"></input>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td><input class="fill" ng-model="echo_Phone" contentEditable="true" placeholder="Mobile Number"></input>
</td>
<td></td>
<td> <a href=""><img src="images/p-l-u-s-off-btn-copy.png"></a></td>
</tr>
<tr>
<td><input class="fill" ng-model="echo_Phone" contentEditable="true" placeholder="Office Number"></input></td>
<td></td>
<td> <a href=""><img src="images/p-l-u-s-off-btn-copy.png"></a></td>
</tr>

<tr>
<td><input class="fill" ng-model="echo_Phone" contentEditable="true" placeholder="Fax Number"></input></td>
<td></td>
<td> <a href=""><img src="images/p-l-u-s-off-btn-copy.png"></a></td>
</tr>

<tr>
<td><input class="fill" ng-model="echo_Email" contentEditable="true" placeholder="Email"></input></td>
<td></td>
<td> <a href=""><img src="images/p-l-u-s-off-btn-copy.png"></a></td>
</tr>

<tr>
<td><input class="fill" ng-model="echo_Website" contentEditable="true" placeholder="Website"></input></td>
<td></td>
<td> <a href=""><img src="images/p-l-u-s-off-btn-copy.png"></a></td>
</tr>

<tr>
<td><input class="fill" ng-model="echo_Street" contentEditable="true" placeholder="Street Addres"></input></td>
<td></td>
<td></td>
</tr>

<tr>
<td><input class="fill" ng-model="echo_Postal" contentEditable="true" placeholder="Postal Addres"></input></td>
<td></td>
<td></td>
</tr>
<tr>
<td><input class="fill" ng-model="echo_Social" contentEditable="true" placeholder="Social"></input></td>
<td></td>
<td></td>
</tr>

</table>
</div>

最佳答案

如果我理解正确的话,您想在用户点击等事件发生后对一个元素执行某些操作。

<div ng-repeat="template in signaturetemplates">
<h2 ng-click="selectedTemplate=template">{{template.name}}</h2>
</div>

//Somewhere else in the code...
<div ng-show="selectedTemplate">
<h2>Selected {{selectedTemplate.name}}</h2>
<pre>{{selectedTemplate.templatesample}}</pre>
<div>

关于javascript - 如何从 ng-repeat 中保存元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32445004/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com