Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ng单击不在ajax数据表中工作+;视频教程_Php_Angularjs_Codeigniter_Datatable_Angular Routing - Fatal编程技术网

Php ng单击不在ajax数据表中工作+;视频教程

Php ng单击不在ajax数据表中工作+;视频教程,php,angularjs,codeigniter,datatable,angular-routing,Php,Angularjs,Codeigniter,Datatable,Angular Routing,我有一个案例,CRUD数据带有编辑和删除数据选项。但我有限制ng click=()无法在控制器ajax_list()调用中工作: 这是我的代码: 用户控制器(CI) 在$row[]中,我从php呈现html,但单击“不工作” 你能帮我吗?尽量避免将PHP用于HTML输出。如果您使用trustAsHtml或类似的东西添加它,angularjs将不会编译它。最好将$item->kode_user以数组形式返回,然后在页面上打印出来。@sintakonte,我认为那篇文章不太合适,因为我的datata

我有一个案例,CRUD数据带有编辑和删除数据选项。但我有限制ng click=()无法在控制器ajax_list()调用中工作:

这是我的代码:

用户控制器(CI)

在$row[]中,我从php呈现html,但单击“不工作”


你能帮我吗?

尽量避免将PHP用于HTML输出。如果您使用
trustAsHtml
或类似的东西添加它,angularjs将不会编译它。最好将
$item->kode_user
以数组形式返回,然后在页面上打印出来。

@sintakonte,我认为那篇文章不太合适,因为我的datatable是服务器端的,这就是问题所在-我很确定angular控制器在你获取数据之前就初始化了-因此angular不可能触发这个点击事件-你需要一个指令或类似的东西-可能最好使用一些库-看看这里
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);
    }
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');
    }
})