我对AngularJS很新。如果问题太简单,请原谅。我有一个与AngularJS一起使用ng-repeat显示的列表。我正在使用bootstrap寻呼机进行寻呼,一次只能选择10条记录。
var start =0;
var end = 10;
results.slice(start, end);
我想自动编号行。
这是我试过的。
使用$ index和ng-repeat。(这很好用,但索引会在第二页重复)
使用
{{sequenceId + 1}}(所有数字显示1)
我想在表格加载时在表格中显示数字。
答案 0 :(得分:0)
class DbHandler {
private $conn;
function __construct() {
require_once dirname(__FILE__) . '/DbConnect.php';
// opening db connection
$db = new DbConnect();
$this->conn = $db->connect();
}
public function createProfile($image, $name) {
$response = array();
$stmt =$this->conn->prepare ("SELECT id FROM uploadimagestoserver ORDER BY id ASC") ;
$id = 0;
while($row = mysqli_fetch_array($response)){
$id = $row['id'];
}
$path = "uploads/$id.png";
$actualpath = "https://localhost/GoodPriceApi/uploadImage/$path";
// insert query
$stmt = $this->conn->prepare("INSERT INTO uploadimagestoserver(image,name) values(?, ?)");
$stmt->bind_param("is", $actualpath, $name);
$result = $stmt->execute();
$new_user_id = $stmt->insert_id;
$stmt->close();
// Check for successful insertion
if ($result) {
file_put_contents($path,base64_decode($image));
// User successfully inserted
return USER_CREATED_SUCCESSFULLY;
} else {
// Failed to create user
return USER_CREATE_FAILED;
}
return $response;
}
}
到您的API并让其回复 <?php
include './DbHandler.php';
$db = new DbHandler();
$response = array();
if (isset($_POST['name']) && $_POST['image'] != '') {
$name = $_POST['name'];
$image = $_POST['image'];
$res = $db->createProfile($name, $image);
if ($res == USER_CREATED_SUCCESSFULLY) {
$response["error"] = false;
$response["message"] = "access granted";
} else if ($res == USER_CREATE_FAILED) {
$response["error"] = true;
$response["message"] = "Sorry! Error occurred in registration.";
}
} else {
$response["error"] = true;
$response["message"] = "Sorry! phone number is not valid or missing.";
}
echo json_encode($response);
?>
另一种选择是将索引存储在某个地方,并使用a 像这样过滤:
app.filter('startFrom',function(){ return函数(输入,开始){ if(输入){ start = + start; //解析为int return input.slice(start); } return []; } });
{{item.Name}}
答案 1 :(得分:0)
像
这样简单的事情./write