Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.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
Javascript ng按特定顺序重复显示html_Javascript_Html_Json_Angularjs - Fatal编程技术网

Javascript ng按特定顺序重复显示html

Javascript ng按特定顺序重复显示html,javascript,html,json,angularjs,Javascript,Html,Json,Angularjs,我收到了json消息: [ { "Question" : { "description" : { "default" : "hello" }, "options" : [ { "value" : { } } ], "title" : { "default" : "hello world" } }, "Selection" : "text", "position" : [ 0, 12, 0 ]

我收到了json消息:

[ { "Question" : { "description" : { "default" : "hello" },
        "options" : [ { "value" : {  } } ],
        "title" : { "default" : "hello world" }
      },
    "Selection" : "text",
    "position" : [ 0,
        12,
        0
      ]
  },
  { "Question" : { "description" : { "default" : "hello 2" },
        "options" : [ { "value" : {  } } ],
        "title" : { "default" : "hello 2" }
      },
    "Selection" : "paragraph",
    "position" : [ 1,
        12,
        0
      ]
  },
  { "Question" : { "description" : { "default" : "hello 3" },
        "options" : [ { "value" : { "default" : "1" } },
            { "value" : { "default" : "2" } }
          ],
        "title" : { "default" : "hello 3" }
      },
    "Selection" : "radio",
    "position" : [ 2,
        12,
        0
      ]
  },
  { "Question" : { "description" : { "default" : "hello 4" },
        "options" : [ { "value" : { "default" : "check11" } },
            { "value" : { "default" : "check22" } }
          ],
        "title" : { "default" : "hello 4" }
      },
    "Selection" : "checkbox",
    "position" : [ 3,
        12,
        0
      ]
  },
  { "Question" : { "description" : { "default" : "hello 5" },
        "options" : [ { "value" : { "default" : "list1" } },
            { "value" : { "default" : "list2" } }
          ],
        "title" : { "default" : "hello 5" }
      },
    "Selection" : "list",
    "position" : [ 4,
        12,
        0
      ]
  }
]
我试图以特定的顺序将json消息加载到html中

您将在json消息中找到位置值,数组中的第一个元素:0表示顺序

有时,json消息是无序的,与示例不同

有没有办法以html的顺序输出json消息:0,1,2,3

HTML部分是:

<div class="container">
            <div ng-repeat="question in questions">
                <div class="row">
                    // load the question in increase order
                </div>
            </div>
        </div>
尝试使用:


...      
尝试使用:


...      
尝试使用:


...      
尝试使用:


...      

您需要将位置数组中的第一项指定给orderBy筛选器:

ng-repeat="question in questions | orderBy:'position[0]'"

您需要将位置数组中的第一项指定给orderBy筛选器:

ng-repeat="question in questions | orderBy:'position[0]'"

您需要将位置数组中的第一项指定给orderBy筛选器:

ng-repeat="question in questions | orderBy:'position[0]'"

您需要将位置数组中的第一项指定给orderBy筛选器:

ng-repeat="question in questions | orderBy:'position[0]'"

您好,我尝试了ng repeat=“问题中的问题|排序人:问题。位置[0]:反转”,但它仍然在orderposition中打印。位置[0]是一个数组,位置[0]会工作吗?如果我想以相反的顺序尝试编写一个函数来确定所需的顺序该怎么办?我尝试了ng repeat=“问题中的问题| orderBy:question.position[0]:reverse”,但它仍然以orderposition打印。position[0]是数组吗?如果我想以相反的顺序尝试编写一个函数来确定所需的顺序该怎么办?我尝试了ng repeat=“问题中的问题| orderBy:question.position[0]:reverse”,但它仍然以orderposition打印。position[0]是数组吗?如果我想以相反的顺序尝试编写一个函数来确定所需的顺序该怎么办?我尝试了ng repeat=“问题中的问题| orderBy:question.position[0]:reverse”,但它仍然以orderposition打印。position[0]是数组吗?如果我想以相反的顺序尝试编写一个函数来确定所需的顺序,该怎么办?嗨,非常感谢!但是我发现如果你在54321中更改json顺序,它将在54321中打印,而不是12345HI中打印,非常感谢!但是我发现如果你在54321中更改json顺序,它将在54321中打印,而不是12345HI中打印,非常感谢!但是我发现如果你在54321中更改json顺序,它将在54321中打印,而不是12345HI中打印,非常感谢!但是我发现如果你在54321中更改json顺序,它将在54321中打印,而不是在12345中打印