我是angularjs的新手,现在遇到了一个问题。尽我最大的努力来解决它,但我无法。
问题:
我有一个自定义指令,它持有一个arraylist。
我必须在带有单选按钮的弹出窗口中显示arraylist对象。
下面是我的代码。
指令 用*标记该行。代码中的arraylist名称为scope.existedClientsList
define([
'angular','app'
], function (angular,app) {
'use strict';
angular
.module('attorneyApp').directive('clientResolution',['internationalizationService','Constant.labels','dataService', 'Constant.urls','displayResult','$timeout','$modal', function (internationalizationService,Constantlabels, dataService, URLs, displayResult,$timeout,$modal) {
return {
restrict: "AE",
templateUrl : 'userinterface/pages/templates/dataentry/clientResolutionTemplate.html',
scope: {
clients: '=',
showaddclient: '&',
filterclientlist: '&',
firststage:'=',
addtolist:'=',
adddisable:'=',
dataentrycreate:'=',
},
link: function (scope, element, attrs,rootScope) {
scope.labels_dataentrydetails=internationalizationService.get(Constantlabels.detaildataentry);
scope.isNotExist=true;
scope.clientExists=false;
**********************************************************************************************************************************************
scope.verifyClient = function (conatctno,index,user_name) {
scope.getclient();
scope.existedClientsList = [];
console.info("To verify whether the client already exists or not");
angular.forEach(scope.clientsArr, function(value2, key2){
if(conatctno === value2.contact_cell_number) {
// console.info("To verify whether the client actual data", value2.contact_cell_number);
var clientObject = {
// 'id':value2.id,
'name':value2.user_name,
'contactno':value2.contact_cell_number
}
scope.existedClientsList.push(clientObject);
// scope.name=value2.user_name
// scope.contactno=value2.contact_cell_number;
scope.isNotExist=false;
// scope.conatctno=conatctno;
scope.index=index;
// $('#myModal').modal('show');
scope.clientExists=true;
}
});
console.info("To verify whether the client already actual data from foundclients", scope.existedClientsList);
if(!scope.clientExists) {
console.info("When no client exists");
var clientObject ={
// 'id':clientid,
'name':user_name,
'contactno':conatctno
}
sccope.existedClientsList.push(clientObject);
// scope.name=user_name;
// scope.contactno=conatctno;
scope.isNotExist=true;
scope.index=index;
$('#myModal').modal('show');
}else{
$('#myModal').modal('show');
}
scope.clientExists=false;
}
******************************************************************************************************************************************************
HTML
<div class="modal-content">
<div class="modal-header">
<button id="btn_1" type="button" class="close" ng-click="hidemodal()">×</button>
<h4 class="modal-title">{{ labels_dataentrydetails.lbl_step2}} {{ labels_dataentrydetails.lbl_client_confirm}}</h4>
</div>
<div class="modal-body">
<div ng-hide="isNotExist">
<div class="moreclients" ng-if="existedClientsList.Length > 1">
Already existed clients are listed below, Do you want to use it? Select any one client from the list.
<div ng-repeat="client in existedClientList">
<input type="radio" name="client" id="lisfOfClients{{$index}}" value="name">
<label>{{client.name}}</label>
</div>>
<button id="addclient_btn" class="btn btn-primary" ng-click="addClient(index)">
<i class="fa fa-plus"></i> {{
labels_dataentrydetails.lbl_new_client }}</button>
</div>