Javascript 在html中打印js文件的动态值

Javascript 在html中打印js文件的动态值,javascript,html,Javascript,Html,我正在开发动态web应用程序。我从JavaSpring控制器获取响应,并在html页面中显示结果。 我有很多领域,如身份证、传播、创建日期、意见、评论。。。在网页上。当直接在网页上打印值时,日期在网页上打印为1485882060000。因此,我使用新的Dateval将其转换为javascript文件中的日期对象,如下所示 MyService.getResults(id).then( function(response) { $scope.results = respons

我正在开发动态web应用程序。我从JavaSpring控制器获取响应,并在html页面中显示结果。 我有很多领域,如身份证、传播、创建日期、意见、评论。。。在网页上。当直接在网页上打印值时,日期在网页上打印为1485882060000。因此,我使用新的Dateval将其转换为javascript文件中的日期对象,如下所示

MyService.getResults(id).then(
    function(response) {
        $scope.results = response;
        angular.forEach($scope.results,function(value,key){
            var startDateRange = new Date(value.startDate);/*Want to print this value in place of {{data.startDate}} in results.html*/
            var endDateRange = new Date(value.endDate);/*Want to print this value in place of {{data.endDate}} in results.html*/
     
        });
    },
    function(errResponse){
        console.error('Error in getResults');
    });
results.html

<div>
    <table>
        <tr>
            <th style="width:5%;">ID</th>
            <th style="width:5%;">Spread%</th>
            <th style="width:15%;">StartDate</th>
            <th style="width:15%;">EndDate</th>
            <th style="width:15%;">Opinion</th>
            <th style="width:20%;">comments</th>
       </tr>
        <tr ng-repeat="data in results
            <td >{{data.id}}</td>
            <td>{{data.spread}}</td>
            <td>{{data.startDate}}</td> /*how to print startDateRange value from javascript file*/
            <td>{{data.EndDate}}</td> /*how to print endDateRange value from javascript file*/
            <td>{{data.Opinion}}</td>
            <td>{{data.Comments}}</td>
</tr>
</table>
</div>
请建议如何在html中动态打印JavaScript变量值。 目前使用上述代码,我将在html页面中打印日期字段,如下所述

代替{data.startDate}显示的值为:1485882060000

代替{data.endDate}显示的值为:149029870000


相反,我想在迭代中打印修改后的javascript变量值startDaterRange和endDateRange。

如果以字符串形式返回日期,则可以将它们转换为JS代码中的日期。Javascript不理解当前格式的日期。

据我所知,您希望将1970年1月1日以来的历元时间戳毫秒转换为日期。可以使用angular的日期过滤器将此值转换为特定的日期格式

<tr ng-repeat="data in results
            <td >{{data.id}}</td>
            <td>{{data.spread}}</td>
            <td>{{data.startDate | date:'yyyy-MM-dd HH:mm:ss'}}</td>
            <td>{{data.EndDate | date:'yyyy-MM-dd'}}</td>
            <td>{{data.Opinion}}</td>
            <td>{{data.Comments}}</td>
</tr>

现在,我可以使用var startDateRange=new Datevalue.startDate将js文件中的日期格式转换为日期格式;我的问题是如何在html文件中打印动态js文件值StartDaterRange。请看我的问题,我不太明白。它当前正在打印什么?您希望它打印什么?我希望打印results.html中的javascript变量startDaterRange、endDaterRange值,而不是我所问的{data.startDate}和{{data.endDate},当前显示的是什么以及显示的预期结果是什么