angualrjs ng-repeat数据切换问题

时间:2017-06-28 01:24:51

标签: angularjs

我有以下代码:`

$scope.getEntitlement = function(selecteEntitlement)
 {
            var finalList=[];
    $scope.EndpointList="";
    $scope.entitlementInfo.forEach(function(entitlement) 
    {
    if(entitlement.attributename == selecteEntitlement)
        {
             finalList.push({endpointname: entitlement.endpointname
                 });
     }
       });
            $scope.EndpointList = finalList;
 };

`说我有3个链接,当我在折叠前一个链接后展开每个链接时,它工作正常。但我面临的问题是,如果我展开第二个链接而不折叠第一个链接,则第二个链接的值将覆盖第一个链接的值。     请帮我解决这个问题。     Java脚本文件具有以下功能:

from bs4 import BeautifulSoup
import pandas as pd

url = "http://www.usatoday.com/sports/mlb/salaries/"

page = requests.get(url)
soup = BeautifulSoup(page.text)

name = []
team = []
pos = []
salary = []
years = []
value = []
annual = []


for row in soup.find_all('tr')[1:]:
    col = row.find_all('td')
    column_1 = col[1].string.strip()
    name.append(column_1)
    column_2 = col[2].string.strip()
    team.append(column_2)
    column_3 = col[3].string.strip()
    pos.append(column_3)
    column_4 = col[4].string.strip()
    salary.append(column_4)
    column_5 = col[5].string.strip()
    years.append(column_5)
    column_6 = col[6].string.strip()
    value.append(column_6)
    column_7 = col[7].string.strip()
    annual.append(column_7)

columns = {
    "name": name,
    "team": team, 
    "pos": pos, 
    "salary": salary, 
    "years": years, 
    "value": value,
    "annual": annual
    }
df = pd.DataFrame(columns)

df.to_csv("somefilename.csv",index = False)

1 个答案:

答案 0 :(得分:0)

您的问题是为每个可展开的点击使用相同的变量$ scope.EndpointList。解决方法是,您为每个ent(EntitlementList中的元素)创建单独的EndpointList,然后您可以使用

ng-repeat="ep in ent.EndpointList"