将angular变量{{$index+1}}转换为javascript整数

Convert the angular{{ $index+1}} variable to a javascript integer

本文关键字:转换 javascript 整数 index+1 angular 变量      更新时间:2023-09-26

我的HTML中有一个隐藏字段,如下所示:

<input id="temp" type="hidden" name="country" value="{{$index + 1}}" ;>

请注意,{{$index+1}}是隐藏标记上方的ng个repeat witten的索引。

现在我正试图获取这个临时隐藏变量的值(试图获取索引的值)。

<script type="text/javascript" >
var tempo = document.getElementById("temp").value;
console.log(tempo); //This gives me {{index+1}} in the alert box insted of the integer value
</script>

我需要执行{{index+1}}%6,并要求结果的类型为integer。

我如何用最简单的形式实现这一点。

问题是:在angular启动之前,您的脚本(var tempo)正在运行。

我的问题是,当你可以使用angular框架时,为什么要使用经典的javascript?

请尝试以下操作:

{{($index+1)%6}}