Answer the question
In order to leave comments, you need to log in
AngularJS ng-click not working?
If you use $scope.showOrder separately, it works fine. But, if placed in ng-repeat , then there is no reaction.
orders.controller.js
app.controller('MakeOrders', ['$scope', '$compile', function($scope, $compile) {
$scope.orders = OrdersArr;
$scope.setOS = function(s){
return (s=='123') ? 'iOS' : 'Android';
}
$scope.setPayStatus = function(s){
return s ? 'оплачено' : 'не оплачено';
}
$scope.setId = function(i){
a = '00000';
return a.substr(0,5-i.toString().length)+i;
}
$scope.showOrder = function(id){
$('.col-lg-3').css('width','30%');
var title_id = '00000'.substr(0,5-id.toString().length)+id;
$('.arrow-back').show();
$('.panel-header h1').text('Заказ №'+title_id);
$('.panel-search-box,.panel-content').hide();
var compiledeHTML = $compile("<div order-Info></div>")($scope);
$(".panel-content").after(compiledeHTML);
}
}]);
app.directive('orderInfo', function() {
return {
templateUrl: '/res/admin/order-info.html'
};
});
<div ng-controller="MakeOrders" class="panel-order-table">
<table>
<tbody>
<tr ng-click="showOrder(1);"><th>№ ЗАКАЗА</th><th>ДАТА И ВРЕМЯ</th><th>ПЛАТФОРМА</th><th>СУММА</th><th>СТАТУС</th></tr>
<tr ng-click="showOrder({{order.id}});" class="panel-order-row" ng-repeat="order in orders">
<td>{{ setId(order.id) }}</td>
<td>{{order.delivery_time | timestampToDate}}</td>
<td>{{ setOS(order.client_id) }}</td>
<td id="order-td-summa">
<span>{{order.amount}} руб.</span>
<span class="paid">{{ setPayStatus(order.pay_status) }}</span>
</td>
<td id="order-td-status">
<span class="sprite-icon order-icon-1"></span>
<span onclick="Orders.StatusBox(true,this);">Принят в обработку</span>
<div id="dropdown-status" class="dropdown-status">
<ul>
<li><span>Принят в обработку</span></li>
<li><span>Ожидает доставки</span></li>
<li><span>Доставлено</span></li>
<li><span>Анулировано</span></li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
</div>
Answer the question
In order to leave comments, you need to log in
Found a general solution. StackoverFlow helped.
Instead showOrder({{order.id}});
ofshowOrder(order.id);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question