0

最初のバージョンは機能するが、2 番目のバージョンは失敗する Uncaught Error: 10 $digest() iterations reached. Aborting!

<table data-role="parsed config viewer">
    <thead>
        <tr>
            <th>name</th>
            <th>client strings</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat="svc in services">
            <td>{{svc.name}}</td>
            <td>{{svc.remoteClients()}}</td>
            <td>
                <button ng-click="getJson('http://'+nodeHost+'/parsed.config?host='+sandbox+'&base='+machineBasePath+case+'&path='+svc.dir+'Web.config',svc,false);">Refresh</button>
            </td>
        </tr>
        <tr ng-repeat="svc in services">
            <td>{{svc.name}}(local)</td>
            <td>
                <ul>
                    <li ng-repeat="slClient in svc.localClients()">{{slClient}}</li>
                </ul>
            </td>
            <td>
                <button ng-click="getJson('http://'+nodeHost+'/parsed.config?host=localhost&base='+localpath+'&path='+svc.dir+'Web.config',svc,true);">Refresh</button>
            </td>
        </tr>
    </tbody>
</table>

JavaScript

if (!Array.prototype.arrayFirst) {
    Array.prototype.arrayFirst = function (predicate, predicateOwner) {
        var array = this || [];
        for (var i = 0, j = array.length; i < j; i++)
        if (predicate.call(predicateOwner, array[i])) return array[i];
        return null;
    };
}
if (!Array.prototype.arrayMap) {
    Array.prototype.arrayMap = function (mapping) {
        var array = this || [];
        var result = [];
        for (var i = 0, j = array.length; i < j; i++)
        result.push(mapping(array[i]));
        return result;
    };
}
var Service = function (name, path, svc, notes) {
    var self = this;
    this.name = name;
    this.path = path;
    this.svc = svc;
    this.notes = notes;
    this.dir = "\\" + path.replace("/", "\\") + "\\";
    this.url = "/" + path.replace("\\", "/") + "/" + svc;

    var getConfig = function (local) {
        var parsed = local ? self.parsedlocal : self.parsed;
        return parsed;
    };

    var getClients = function (local) {
        var parsed = getConfig(local);
        if (!parsed) return ["not attempted"];
        if (!parsed.configuration) return ["no configuration"];
        if (!parsed.configuration['system.serviceModel']) return ["No Service Model"];
        var clients = parsed.configuration['system.serviceModel'][0].
        client[0].endpoint.arrayMap(function (a) {
            return {
                name: a.$.name,
                address: a.$.address
            };
        });

        return clients;
    };
    this.localClients = function () {
        console.log('getting local clients');
        return getClients(true);
    };
    this.remoteClients = function () {
        console.log('getting remote clients');
        return getClients(false);
    };
};
var PublishCtrl = function ($scope, $http, $timeout) {
    window.publishCtrl = $scope;
    $scope.getJson = function (uri, svc, local) {
        console.log('get json!');

        //window.parsed= data;
        if (local) {
            var newParsed = {
                configuration: {
                    'system.serviceModel': [{
                        client: [{
                            endpoint: [{
                                $: {
                                    name: 'localabc'
                                }
                            }, {
                                $: {
                                    name: 'localcba'
                                }
                            }]
                        }]
                    }]
                }
            };
            if (newParsed != svc.parsedLocal) {
                console.log('updating parsedlocal');
                svc.parsedlocal = newParsed;
            }
        } else {
            console.log('updating parsed');
            svc.parsed = {
                configuration: {
                    'system.serviceModel': [{
                        client: [{
                            endpoint: [{
                                $: {
                                    name: 'remoteabc'
                                }
                            }, {
                                $: {
                                    name: 'remotecba'
                                }
                            }]
                        }]
                    }]
                }
            };
        }

    };
    $scope.services = [
    new Service("Wcf Portal", "Services.Host", "WcfPortal.svc"),
    new Service("Registration Portal", "Services.Host.Registration", "WcfPortal.svc"),
    new Service("Program Pricing", "Services.Host.ProgramPricing", "ProgramPricingService.svc"),
    new Service("Data Lookup", "DataLookupService", "DataLookupService.svc", "path depth issues"),
    new Service("DocumentPrintingService", "Services.Host.PrintingService", "DocumentPrintingService.svc")];
};

http://jsfiddle.net/Maslow/j9Jes/

4

0 に答える 0