0

I'm trying to print the laravel error through angularjs, i have done but there is problem inside the code. Script is also showing square bracket and double quote.

Validation in Controller

$this->validate($request, [
    'email' => 'required|email',
]);

In AngularJs

request.error(function (error) {
    $scope.mError = error.email;
    $scope.loader=false;
});

In HTML

<div class="err" ng-if="mError">@{{ mError }}</div>

**OutPut**
["The email must be a valid email address."]

Can anyone guide me how can i prevent to print the double quotes and square brackets with error? I would like to appreciate. Thank You

Ayaz Ali Shah
  • 3,453
  • 9
  • 36
  • 68

1 Answers1

0
if (str.charAt(0) === '[' && str.charAt(1) === '"'&& str.charAt(str.length -2) === '"' && str.charAt(str.length -1) === '"')
 {
     console.log(str.substr(2,str.length -3));
  }

Also read this helps you

I want to remove double quotes from a String

Community
  • 1
  • 1
Parthasarathy
  • 308
  • 2
  • 10