简体   繁体   English

将ng-repeat的AngularJS对象值传递给AngularJS函数

[英]pass AngularJS object value from ng-repeat to AngularJS function

I am trying desperately to pass a Angular object value onto a function. 我拼命试图将Angular对象值传递到函数上。 The various attempts have resulted in no progress, and the only time I got it to work properly when I hard code the values. 各种尝试都没有取得任何进展,并且只有当我对值进行硬编码时,才使它能够正常工作。

The MVC View: MVC视图:

<tr ng-repeat="project in projects | filter:search:strict">
<td><span><a style="cursor:default" title="Ändra i projektet.." id="{{project.id}}" data-ng-click="opents('/EditProject/', '{{ project.id }}')">{{ project.id }}</a></span></td>

The Angular function: Angular函数:

$scope.opents = function (tsUrl, id) {
        alert('/EditProject/'+ $attrs);
        alert(tsUrl);
        alert(id);
        alert(tsUrl + id);
        TINY.box.show({ url: tsUrl + id });
    };

I've tried to recieve different values from the invoke in the view, hence the many alerts. 我试图从视图中的调用接收不同的值,因此有很多警报。 Can't find a solution for this from the web and hope someone knows of a solution. 无法从网上找到解决方案,希望有人知道解决方案。

尝试:

ng-click="opents('/EditProject/', project.id)"

UPDATE: 更新:

From the view I used $event instead. 从视图中,我改用$ event。

ng-click="opents('/PopUp2/EditProject/', $event)

and in the function: 并在函数中:

$scope.opents = function (tsUrl, e) {
        var id = e.currentTarget.innerText;
        TINY.box.show({ url: tsUrl + id });

and got a functional respons. 得到了功能上的回应 Hope this helpt someone else! 希望这对别人有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM