Reputation: 314
I am trying to pull data from my database to display into a form, but I keep getting this error Error: [$parse:lexerr] http://errors.angularjs.org/1.2.21/$parse/lexerr?p0=Unterminated%20quote&p1=s%2055-56%20%5B'%5D&p2=report.incidentTime%20%3D'Couple'sNaNispute%20at%20Robinson%20Hall'. I'm using laravel and angularjs (hybrid approach) in this web app.
HTML
<div class="col-xs-4 col-sm-4 col-md-4">
<div class="form-group" data-ng-class="{'has-error': documentIncident.reportTitle.$invalid && documentIncident.reportTitle.$dirty}">
<label for="incidentTime">Report Title</label>
<input type="text" name="reportTitle" ng-model="report.reportTitle" ng-init=" report.incidentTime ='{{$reports[0]->reportTitle}}'" autocomplete="off" ng-minlength="6" class="form-control input-sm" required>
</div>
</div>
DB data
The problem I am having is that the apostrophe is preventing the data from being shown. Is there a way to get around this, whether through filtering, escaping or any other approach?
Upvotes: 0
Views: 1118
Reputation: 4302
The issue is that after laravel is done rendering into your template it looks like this:
ng-init="report.incidentTime ='Couple's dispute at Robinson Hall'"
Which causes the exception because of the unmatched ' in Couple's. What you need to do is
Upvotes: 1