如何在angularjs中的下方按钮中应用确认对话框?
<button class="btn btn-sm btn-danger" ng-click="removeUser($index)">Delete</button>
Run Code Online (Sandbox Code Playgroud)
像这样.
<span><a class="button" onclick="return confirm('Are you sure to delete this record ?')" href="delete/{{ item.id }}">Delete</span>
Run Code Online (Sandbox Code Playgroud)
更新
目前我这样做
function removeUser(index) {
var isConfirmed = confirm("Are you sure to delete this record ?");
if(isConfirmed){
vm.users.splice(index, 1);
}else{
return false;
}
};
Run Code Online (Sandbox Code Playgroud) 我有像这样的图像上传ajax
$scope.uploadFile = function(){
var file = $scope.myFile;
console.log(file);
var uploadUrl = "/api/upload_image";//It will also goes to '/api/get_data'
//fileUpload.uploadFileToUrl(file, uploadUrl);
var fd = new FormData();
fd.append('file', file);
$http.post(uploadUrl, fd, {
transformRequest: angular.identity,
headers: {'Content-Type': undefined}
})
.success(function(e){
console.log("Success");
})
.error(function(e){
console.log("Error");
});
};
Run Code Online (Sandbox Code Playgroud)
并调用提交形式像这样的ajax.
$http({
url: "/api/get_data",
method: "POST",
dataType:"json",
data:JSON.stringify(this.formData)
}).success(function(data) {
console.log("Success");
}).error(function(error) {
console.log("Error");
});
Run Code Online (Sandbox Code Playgroud)
两者都在工作但是分开,如何将这两个ajax组合成一个,即提交ajax,第二个.
或者有没有办法在第二个ajax中发布图像数据,我使用的是angular + laravel5.2
我在角度视图中的文件输入是
<input type="file" file-model="myFile">
Run Code Online (Sandbox Code Playgroud)
谢谢.
我在上传所有更改后收到此错误
[error] [client XX.XX.XX.XX] Application.cpp中的SoftException:254:文件"/root_path/public/index.php"可按组写入
这个错误意味着什么,我该如何解决这个问题.
谢谢
我有一张test有 4 列的桌子
id name visited updated_at
1 abc 2016-03-20 2016-03-20
2 xyz 2016-03-23 2016-03-23
Run Code Online (Sandbox Code Playgroud)
当我申请以下查询时
ALTER TABLE `test` CHANGE `updated_at` `updated_at` TIMESTAMP on update
CURRENT_TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00';
Run Code Online (Sandbox Code Playgroud)
如果我更改name或更改visited,它会更改 updated_at
但我想它只有在visited改变时才会改变。
如何实现这一目标?谢谢你的帮助。
我在同一时间插入多行,比如2行
$multiple_rows = [
['email' => 'taylor@example.com', 'votes' => 0],
['email' => 'dayle@example.com', 'votes' => 0]
];
DB::table('users')->insert($multiple_rows);
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得那些插入的ID.
我这样做,现在就这样.
foreach($multiple_rows as $row){
DB::table('users')->insert($row);
$record_ids[] = DB::getPdo()->lastInsertId();
}
Run Code Online (Sandbox Code Playgroud)
任何其他好的方法,每次都不插入单行.
angularjs ×2
javascript ×2
laravel ×2
php ×2
ajax ×1
forms ×1
laravel-5.2 ×1
mysql ×1
sql ×1
timestamp ×1