存储NG重复指令的第一要素 [英] Store first element of ng-repeat directive

查看:121
本文介绍了存储NG重复指令的第一要素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

进出口新的角度。

我有一个 NG-重复指令,我想存储答案之一属性全局变量。

I have a ng-repeat directive and I would like to store one of the answer attribute in a "global" variable.

我想成才这样

var buffer = answer.discussionId;
<div ng-repeat="answer in answers">
    if(buffer != answer.discussion){
        //do something
        buffer = answer.discussionId;
    }    
</div>

感谢您

推荐答案

我相信会有一个黑客做到这一点。但你永远不应该的角度做到这一点。做到这一点在你的控制器!

I am sure there will be a hack to do this. But you should never do this in angular. Do it in your controller!

这篇关于存储NG重复指令的第一要素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆