Как получить доступ к данным из пользовательской директивы для отображения во всплывающем окне - PullRequest
0 голосов
/ 25 февраля 2019

Я новичок в angularjs и столкнулся с проблемой.Попробовал мой уровень, чтобы решить его, но я не смог.

ВЫПУСК: У меня есть специальная директива, и она содержит 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()">&times;</button>
            <h4 class="modal-title">{{ labels_dataentrydetails.lbl_step2}}&nbsp;&nbsp;{{ 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>&nbsp;&nbsp;{{
                            labels_dataentrydetails.lbl_new_client }}</button>
                    </div>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...