Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.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
Angularjs 使用ng repeat处理数据流_Angularjs_Angularjs Ng Repeat_Ng Repeat_Eventsource - Fatal编程技术网

Angularjs 使用ng repeat处理数据流

Angularjs 使用ng repeat处理数据流,angularjs,angularjs-ng-repeat,ng-repeat,eventsource,Angularjs,Angularjs Ng Repeat,Ng Repeat,Eventsource,我从EventSource接口获得了以下数据。我正在使用这些数据使用angular ng repeat构建一个简单的表(我在下面指定了表结构)。我遇到的问题是,数据变化很快,即服务器将持续发送所请求符号的变化,然后它将继续更新值。我想在为符号请求数据时添加一行,然后为新值更新同一行。这很简单,而且很有效 但真正的挑战是(至少对我来说)当我请求另一个符号时,我希望它被添加到新的第二行,从现在起,它应该更新两行中的值。当我们要求新的符号时,它继续。使用以下数据结构是否可行,如果可能,请解释 数据结构

我从EventSource接口获得了以下数据。我正在使用这些数据使用angular ng repeat构建一个简单的表(我在下面指定了表结构)。我遇到的问题是,数据变化很快,即服务器将持续发送所请求符号的变化,然后它将继续更新值。我想在为符号请求数据时添加一行,然后为新值更新同一行。这很简单,而且很有效

但真正的挑战是(至少对我来说)当我请求另一个符号时,我希望它被添加到新的第二行,从现在起,它应该更新两行中的值。当我们要求新的符号时,它继续。使用以下数据结构是否可行,如果可能,请解释

数据结构:

data = [
  AMZN: {
    name: Amazon,
    symbol: AMZN,
    openPrice: $100,
    latestPrice: $200,
    percentage: 0.1
 },
 FB: {
    name: Facebook,
    symbol: FB,
    openPrice: $150,
    latestPrice: $250,
    percentage: 0.2
 }
]
<table>
        <thead>
            <tr>
                <th>Session ID</th>
                <th>Company Name</th>
                <th>Symbol</th>
                <th>Open Price</th>
                <th>Latest Price</th>
                <th>Percentage</th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="stockVal in data">
                <td>[Empty]</td>
                <td>{{stockVal.companyName}}</td>
                <td>{{stockVal.companySymbol}}</td>
                <td>{{stockVal.openPrice}}</td>
                <td>{{stockVal.latestPrice}}</td>
                <td>{{stockVal.percentage}}</td>
            </tr>
        </tbody>
    </table>
表格结构:

data = [
  AMZN: {
    name: Amazon,
    symbol: AMZN,
    openPrice: $100,
    latestPrice: $200,
    percentage: 0.1
 },
 FB: {
    name: Facebook,
    symbol: FB,
    openPrice: $150,
    latestPrice: $250,
    percentage: 0.2
 }
]
<table>
        <thead>
            <tr>
                <th>Session ID</th>
                <th>Company Name</th>
                <th>Symbol</th>
                <th>Open Price</th>
                <th>Latest Price</th>
                <th>Percentage</th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="stockVal in data">
                <td>[Empty]</td>
                <td>{{stockVal.companyName}}</td>
                <td>{{stockVal.companySymbol}}</td>
                <td>{{stockVal.openPrice}}</td>
                <td>{{stockVal.latestPrice}}</td>
                <td>{{stockVal.percentage}}</td>
            </tr>
        </tbody>
    </table>

请添加一些更真实的代码我添加了控制器代码以供参考。