Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/407.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么只渲染数组就可以了,而ng在上面重复却失败了?_Javascript_Angularjs_Angularjs Ng Repeat - Fatal编程技术网

Javascript 为什么只渲染数组就可以了,而ng在上面重复却失败了?

Javascript 为什么只渲染数组就可以了,而ng在上面重复却失败了?,javascript,angularjs,angularjs-ng-repeat,Javascript,Angularjs,Angularjs Ng Repeat,第一个版本有效,第二个版本失败 Uncaught错误:已达到10$digest()次迭代。流产 <table data-role="parsed config viewer"> <thead> <tr> <th>name</th> <th>client strings</th> <th></th>

第一个版本有效,第二个版本失败
Uncaught错误:已达到10$digest()次迭代。流产

<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>

名称
客户端字符串
{{svc.name}
{{svc.remoteClients()}}
刷新
{{svc.name}}(本地)
  • {{slClient}
刷新
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")];
};
if(!Array.prototype.arrayFirst){
Array.prototype.arrayFirst=函数(谓词,谓词所有者){
var数组=此| |[];
对于(var i=0,j=array.length;i

svc.localClients()
是否返回正确的对象或数组?如果给出如此大的代码,请提供一个fiddle或plunk。“我们不可能这样看它。”阿比利什提供了小提琴