Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.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 - Fatal编程技术网

Angularjs 如何从ng repeat中仅重命名一个字符串

Angularjs 如何从ng repeat中仅重命名一个字符串,angularjs,Angularjs,参考下面的代码,我得到 0: {status: "DRAFT", $$hashKey: "object:282"} 1: {status: "SUBMITTED", $$hashKey: "object:283"} 2: {status: "APPROVED", $$hashKey: "object:284"} 3: {status: "REJECTED", $$hashKey: "object:285"} 4: {status: "RESUBMIT", $$hashKey: "obje

参考下面的代码,我得到

0: {status: "DRAFT", $$hashKey: "object:282"}

1: {status: "SUBMITTED", $$hashKey: "object:283"}

2: {status: "APPROVED", $$hashKey: "object:284"}

3: {status: "REJECTED", $$hashKey: "object:285"}

4: {status: "RESUBMIT", $$hashKey: "object:286"}

5: {status: "APPROVAL_NR", $$hashKey: "object:287"}
length: 6
__proto__: Array(0)
作为“statusdata”中的响应,我使用ng repeat将这些数据显示为下拉列表。我想重命名视图中的最后一个“批准号”。

来自angular docs: 您可以使用$last

$last   boolean true if the repeated element is last in the iterator.
您也可以检查此项:。 我将按照以下方式实施它:

function renameIfLast(name, isLast) {
  if (isLast) {
    return name.toUpperCase(); // do you rename logic here <<
  } else {
    return name;
  }
}

<h1 ng-repeat="x in records">{{renameIfLast(x.status, $last)}}</h1>
函数renameIfLast(名称,isLast){
如果(isLast){

return name.toUpperCase();//是否在此处重命名逻辑我不仅要获取最后一个值。我只想将该列表中的最后一个值重命名为其他名称
toUpperCase
是一个function@charlietfl我猜scala太多了:)@Varvarigos Emmanouil..$last帮助解决了这个问题。谢谢