Angular: 1.4.3
I'm try to inject some dynamic html using ngInclude, ngRepeat and the $index, but I'm having some troubles on ngClick,
something like that:
myApp.controller('myController', ['$scope', '$compile', function($scope, $compile) {
$scope.start = function(){
var myController = angular.element(document.getElementById("myController"));
var dynamicContainers = angular.element(document.getElementById("dynamicContainers"));
dynamicContainers.html('<ul id="sortableConfig2" style="list-style-type"> <li class="col-md-6 col-sm-6 ui-state-default" id={{$index}} ng-include="\'./resources/includes/include3.html\'" ng-repeat="item in [0,1,2,3,4,5]" > </li></ul>');
myController.scope().activateView(dynamicContainers);
}
$scope.activateView = function(ele) {
$compile(ele.contents())($scope);
$scope.$apply();
};
$scope.start();
}]);
And inside the include3.html a have some codes, all using the $index to keep the dynamism.
<div id="panel{{$index}}hover" class="icons_edit_card">
<i class="fa fa-cog ng-bind" ng-click="showConfigPanel($index)"></i>
<i class="fa fa-pencil ng-bind" ng-click='showTypePanel($index)'></i>
</div>
<div class="overlay">
<div id="panel{{$index}}overlay" class="container-modal-dashboard">
<div class="title-modal-dashboard" style="padding-bottom: 4px;" ng-show="paineis[{{$index}}].show">Placar - {{paineis[$index].type}} de Vendas</div>
...
All the "$index" are being interpolated, except on ng-click
- If use
ng-click="showConfigPanel($index)" the html doesn't interpolate and inspecting the element it appears as ng-click="showConfigPanel($index)"
- If I use
ng-click="showConfigPanel({{$index}})" it shows "Error: [$parse:syntax] Syntax Error: Token '{' invalid key ..."
- And if a use
ng-click="showConfigPanel('{{$index}}')" the html is rendered as ng-click="showConfigPanel('0')" but if I click on it link the value passed to the function is '{{$index}}' not 0
I tried the solution in this issue #4627, something like that ng-click="showConfigPanel(''+$index)" or ng-click="showConfigPanel('test'+$index)" but it stills writing literally the "$index"
Exist any workarround on it?
Angular: 1.4.3
I'm try to inject some dynamic html using ngInclude, ngRepeat and the $index, but I'm having some troubles on ngClick,
something like that:
And inside the
include3.htmla have some codes, all using the $index to keep the dynamism.All the
"$index"are being interpolated, except onng-clickng-click="showConfigPanel($index)"the html doesn't interpolate and inspecting the element it appears asng-click="showConfigPanel($index)"ng-click="showConfigPanel({{$index}})"it shows"Error: [$parse:syntax] Syntax Error: Token '{' invalid key ..."ng-click="showConfigPanel('{{$index}}')"the html is rendered asng-click="showConfigPanel('0')"but if I click on it link the value passed to the function is'{{$index}}'not0I tried the solution in this issue #4627, something like that
ng-click="showConfigPanel(''+$index)"orng-click="showConfigPanel('test'+$index)"but it stills writing literally the"$index"Exist any workarround on it?