Javascript 如何在angularjs的md列表项中添加临时值?
我正在尝试使用材质图标在列表中添加一些项目。通过Javascript 如何在angularjs的md列表项中添加临时值?,javascript,css,angularjs,html,Javascript,Css,Angularjs,Html,我正在尝试使用材质图标在列表中添加一些项目。通过ng click=“contactDetails.contactModes.push(numbers);”在此处永久添加项目 我在卡片底部有两个按钮,即保存和放弃。但问题是,无论何时单击材质图标,都会将值添加到列表中。表示不使用丢弃。我的目标是在列表中添加临时值,这样当用户单击saved时,只有值被保存,否则将被丢弃 请建议 我的代码: <md-list-item ng-show="showContactList" class="md-2-l
ng click=“contactDetails.contactModes.push(numbers);”
在此处永久添加项目
我在卡片底部有两个按钮,即保存和放弃。但问题是,无论何时单击材质图标,都会将值添加到列表中。表示不使用丢弃。我的目标是在列表中添加临时值,这样当用户单击saved时,只有值被保存,否则将被丢弃
请建议我的代码:
<md-list-item ng-show="showContactList" class="md-2-line" ng-repeat="numbers in contactList" ng-click="contactDetails.contactModes.push(numbers);">
<i ng-show="numbers.type == 'sample'" class="material-icons md-avatar-icon">textsms</i>
<i ng-show="numbers.type == 'CELL' || numbers.type == 'EXT'" class="material-icons md-avatar-icon">phone</i>
<img class="pad-right-5 md-avatar dime-30" ng-show="numbers.type == 'PAGER'" src="assets/img/contact-pref/pager.png" width="26" style="width:30px;height:28px;margin-left: 5px;">
<div class="md-list-item-text" ng-class="{'md-offset': phone.options.offset }">
<h3> {{ numbers.type }} </h3>
<p> {{ numbers.value }} </p>
</div>
<i class="material-icons md-avatar-icon add-rm-icon margin-right">add</i>
</md-list-item>
短信
电话
{{numbers.type}
{{numbers.value}}
添加
请建议。我在控制器中使用了临时变量
$scope.arrayText = [{
"type": "sample",
"value": "test"
}];
并在代码中进行以下更改,以添加临时和最终使用contactDetails.contactModes=arrayText on ng单击使用保存按钮永久添加
<md-list-item ng-show="showContactList" class="md-2-line" ng-repeat="numbers in contactList" >
<i ng-show="numbers.type == 'TruliaCare'" class="material-icons md-avatar-icon">textsms</i>
<i ng-show="numbers.type == 'CELL' || numbers.type == 'EXT'" class="material-icons md-avatar-icon">phone</i>
<img class="pad-right-5 md-avatar dime-30" ng-show="numbers.type == 'PAGER'" src="assets/img/contact-pref/pager.png" width="26" style="width:30px;height:28px;margin-left: 5px;">
<div class="md-list-item-text" ng-class="{'md-offset': phone.options.offset }">
<h3> {{ numbers.type }} </h3>
<p> {{ numbers.value }} </p>
</div>
<i class="material-icons md-avatar-icon add-rm-icon margin-right" ng-click="arrayText.push(numbers);">add</i>
</md-list-item>
短信
电话
{{numbers.type}
{{numbers.value}}
添加
我在控制器中使用了临时变量
$scope.arrayText = [{
"type": "sample",
"value": "test"
}];
并在代码中进行以下更改,以添加临时和最终使用contactDetails.contactModes=arrayText on ng单击使用保存按钮永久添加
<md-list-item ng-show="showContactList" class="md-2-line" ng-repeat="numbers in contactList" >
<i ng-show="numbers.type == 'TruliaCare'" class="material-icons md-avatar-icon">textsms</i>
<i ng-show="numbers.type == 'CELL' || numbers.type == 'EXT'" class="material-icons md-avatar-icon">phone</i>
<img class="pad-right-5 md-avatar dime-30" ng-show="numbers.type == 'PAGER'" src="assets/img/contact-pref/pager.png" width="26" style="width:30px;height:28px;margin-left: 5px;">
<div class="md-list-item-text" ng-class="{'md-offset': phone.options.offset }">
<h3> {{ numbers.type }} </h3>
<p> {{ numbers.value }} </p>
</div>
<i class="material-icons md-avatar-icon add-rm-icon margin-right" ng-click="arrayText.push(numbers);">add</i>
</md-list-item>
短信
电话
{{numbers.type}
{{numbers.value}}
添加