从角度控制器发布数据后数组为空

时间:2017-06-01 10:20:19

标签: javascript php angularjs arrays codeigniter

我正在为我的应用使用codeigniter和angular。当我将数据从角度控制器发布到CI控制器时,数组似乎是空的(print_r的结果是" array()")。有人告诉我为什么?

Angular Part:

public function dodajBazi() {
    $info = $this->input->post();
    print_r($info);
}

CI部分

private static final int REQUEST_PERMISSIONS = 100;
  private static final String PERMISSIONS_REQUIRED[] = new String[]{

            Manifest.permission.READ_CONTACTS,Manifest.permission.RECORD_AUDIO

    };

    private boolean checkPermission(String permissions[]) {
        for (String permission : permissions) {
            if (ContextCompat.checkSelfPermission(getApplicationContext(), permission) != PackageManager.PERMISSION_GRANTED) {
                return false;
            }
        }
        return true;
    }

    private void checkPermissions() {
        boolean permissionsGranted = checkPermission(PERMISSIONS_REQUIRED);
        if (permissionsGranted) {
            Toast.makeText(this, "You've granted all required permissions!", Toast.LENGTH_SHORT).show();
        } else {
            boolean showRationale = true;
            for (String permission : PERMISSIONS_REQUIRED) {
                showRationale = ActivityCompat.shouldShowRequestPermissionRationale(this, permission);
                if (!showRationale) {
                    break;
                }
            }

            String dialogMsg = showRationale ? "We need some permissions to run this APP!" : "You've declined the required permissions, please grant them from your phone settings";

            new AlertDialog.Builder(this)
                    .setTitle("Permissions Required")
                    .setMessage(dialogMsg)
                    .setCancelable(false)
                    .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            ActivityCompat.requestPermissions(mActivity, PERMISSIONS_REQUIRED, REQUEST_PERMISSIONS);
                        }
                    }).create().show();
        }
    }

1 个答案:

答案 0 :(得分:0)

您需要使用默认内容类型标题

试试这个:

$http({
   method: 'POST',
   url: 'http://localhost/psi/Pravljenjejela/dodajBazi',
   data: $scope.prosek,
   headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).then(function (res) {
   $window.location.href = "http://localhost/psi/Pravljenjejela/dodajBazi";
}, function (err) {
 console.log(err);
});