for (var i = 'A', k = 1; i <= 'Z', k <= $scope.noOfColumns; i = $scope.nextChar(i), k++)
{
for (var j = 1; j <= $scope.noOfSeatsperRow; j++)
{
seats += '<div id=' + i + '' + j + ' class="seat" ng-click="selectOrDeselect($event)">'+ i + '' + j + '</div>';
if (j == $scope.noOfSeatsperRow)
{
seats += '<br />';
}
if (j == $scope.noOfSeatsperRow/2)
{
seats += '<div class="gap"></div>';
}
}
}
angular.element(document.getElementsByClassName("seats")).html(seats);
这里我将一些HTML附加到预先存在的元素。问题是每当我点击ng-click
事件应该调用但没有发生时
我尝试在视图中静态使用for razor循环,我可以调用ng-click
事件
问题是什么?如何克服这个问题?
答案 0 :(得分:0)
for (var i = 'A', k = 1; i <= 'Z', k <= $scope.noOfColumns; i = $scope.nextChar(i), k++)
{
for (var j = 1; j <= $scope.noOfSeatsperRow; j++)
{
seats += '<div id=' + i + '' + j + ' class="seat" ng-click="selectOrDeselect($event)">' + i + '' + j + '</div>';
if (j == $scope.noOfSeatsperRow)
{
seats += '<br />';
}
if (j == $scope.noOfSeatsperRow/2)
{
seats += '<div class="gap"></div>';
}
}
}
angular.element(document.getElementsByClassName("seats")).append($compile(seats)($scope));
我使用&#34;附加($ compile(seat)($ scope));&#34;做到了。