ng-click не работает в ajax datatable + codeigniter

У меня есть случай, данные CRUD с возможностью редактирования и удаления данных. Но у меня есть ограничения ng-click = () не может работать в вызове контроллера ajax_list ():

это мой код:

UserController (ДИ)

public function ajax_list(){
$lists = $this->model_user->get_datatables();
$data = array();
$no = $_POST['start'];
$nomor = 1;
foreach($lists as $key => $item){
$no++;
$row = array();
$row[] = $item->username;
$row[] = '<a type="button" class="btn btn-xs btn-warning" href="#/editUser/'.$item->kode_user.'" title="Edit" ><i class="fa fa-pencil" ></i></a>
<button type="button" class="btn btn-xs btn-danger" ng-click="deleteUser()" title="Hapus"><i class="fa fa-trash"></i></button>';
$data[] = $row;
}
$output = array(
"draw" => $_POST['draw'],
"recordsTotal" => $this->model_user->count_all(),
"recordsFiltered" => $this->model_user->count_filtered(),
"data" => $data
);
echo json_encode($output);
}

script.js (angularjs)

var inticafeApp = angular.module('inticafeApp', ['ngRoute']);
inticafeApp.config(function ($routeProvider, $locationProvider) {
$locationProvider.hashPrefix('');
$routeProvider
.when('/', {
templateUrl: 'dashboard/index',
controller: 'dashboardController'
})

.when('/user', {
templateUrl: 'masterdata/user',
controller: 'userListController'
})

});

inticafeApp.controller('userListController', function ($scope) {
$scope.deleteUser = function () {
// $http.post(siteUrl + "masterdata/user/delete" + id).success(function (response) { alert('yes')})
alert('a');
}
})

в $ row [] я отрисовываю HTML от php, но ngclick не работает.

вы не могли бы мне помочь?

0

Решение

Старайтесь избегать использования PHP для вывода HTML. Он не будет скомпилирован angularjs, если вы добавите его trustAsHtml или что-то типа того. Лучше просто вернуть $item->kode_user в массиве, а затем использовать нг-повтор распечатать его на странице.

0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector