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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/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中的数组中获取特定元素_Angularjs_Angularjs Directive - Fatal编程技术网

从Angularjs中的数组中获取特定元素

从Angularjs中的数组中获取特定元素,angularjs,angularjs-directive,Angularjs,Angularjs Directive,我有一个数组,我想使用指令(例如array[0])从中获取特定元素,但我不知道如何实现它。我意识到这是angularjs的基础,但我找不到任何解决方案。请帮忙:) 这是数组 $scope.array = [ { text: '1', }, { text: '2', }, { text: '3', }] 我使用这种结构是为了 <div ng-repeat="ele

我有一个数组,我想使用指令(例如array[0])从中获取特定元素,但我不知道如何实现它。我意识到这是angularjs的基础,但我找不到任何解决方案。请帮忙:)

这是数组

    $scope.array = [
      {
        text: '1',
      },
      {
        text: '2',
      },
      {
        text: '3',
      }]
我使用这种结构是为了

<div ng-repeat="element in array">
     <content></content>
</div>

这就是包含该指令的内容

<p>{{array.text}}</p>
{{array.text}

在html中: 在内容指令中,您必须添加
bindToController:{data:=“}

您可以在指令中设置相同的变量,而不是
数据

<div ng-repeat="element in array">
     <content></content>
</div>
指令:

<p>{{element.text}}</p>
<p>{{customer.text}}</p>
{{customer.text}


要在指令中显示元素吗?是的,我忘了提到:)然后我应该写什么来调用特定元素?我认为它应该是类似于“否”的,您只需在执行时说,数据中的第一次数组[0],第二次数组[1],第三次数组[2]
<p>{{customer.text}}</p>