Kuy*_*a A 6 laravel angularjs angularjs-service laravel-validation laravel-5.1
嗨我在laravel 5现有验证中遇到了问题.
在我的控制器和请求中.
class PostEmailRequest extends Request{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => 'required|max:255',
];
}}
Run Code Online (Sandbox Code Playgroud)
它将返回电子邮件的验证作为示例.我想用angularjs做什么是我想要捕获验证并在我的前端表单上获取它.它不会重新加载页面.你对这个有什么想法吗?
我的应用程序中的表单将通过angularjs发送数据.$ http post url"app/postPage"如果它的错误高于我的代码将$ validation-> messages()发送到我的angularjs.
您可以执行以下操作。
POST验证路线,例如 myapp.com/validateEmail$http。可以说
EmailJSON在 angularjs 控制器的作用域模型中阅读此内容。在success()下面的代码中。
$http.post('/someUrl', {msg:'hello word!'}).
success(function(data, status, headers, config) {
// this callback will be called asynchronously
// when the response is available
}).
error(function(data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
Run Code Online (Sandbox Code Playgroud)根据 中的范围显示适当的错误HTML。
| 归档时间: |
|
| 查看次数: |
906 次 |
| 最近记录: |