AngularJS ng-click not invoked with {{$index}} used

天涯浪子 提交于 2019-12-03 11:42:57

The value of the ng-click attribute is evaluated as an angular expression, so simply use remove($index).

solved!

<div ng-repeat="idiomax in textos.idiomas ">
    <div class="idioma"  ng-click="cambiaridioma($index)" ng-class="idioma != $index || 'idioma-activo'" > 
    {{idiomax.idioma}}
    </div>
</div>

$scope.cambiaridioma = function (indice) {
        $scope.idioma = indice;

    }

I had to use $index in a string expression and this is how it worked:

HTML

<button ng-click="showUserStories($event, '#modal-id-prefix-' + $index)">Show Modal</button>

Script

$scope.showUserStories = function(event, modalId) {
        $(modalId).modal("show");
        event.stopPropagation();
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!