AngularJS-service城市去重

来源:互联网 发布:野火六大门派源码 编辑:程序博客网 时间:2024/06/15 16:21


/** * 城市去重 * */MetronicApp.service('CollectionUtils', ['$cacheFactory', '$location', function ($cacheFactory, $location) {    this.removeDuplicate = function (dataList) {        var flagList = [];        var cityIdList = [];        angular.forEach(dataList, function (item) {            if (flagList.indexOf(item.id) < 0) {                flagList.push(item.id);                cityIdList.push({                    'province': item.province,                    'city': item.city,                    'county': item.county,                    'cityId': item.id,                });            }        });        return cityIdList;    }        this.notChangedField = function(oldList,newList,field){    var length = oldList.length;    for(var i=0;i<length;i++){    if(oldList[i][field] != newList[i][field]){    return false;    }    }    return true;    }}]);




原创粉丝点击