Laravel {!! Form::open() !!} doesn't work within AngularJS
I'm using Laravel 5.0 + AngularJS
to build some website. The problem is when I use laravel illuminate, things like
{!! Form::open() !!}
{!! Form::close() !!}
are not compiled into forms, instead, the plain texts are displayed.
I guess it's because I'm also using angular, which already have certain use of '{}
';
when I use {!! Form::open() !!}
in another page with no angular it works normally.
How can I use laravel form inside angular app? (need the features like csrf token)
Answer
You will either need to change the blade syntax for laravel or change it for AngularJS. I tend to lean on changing it for Lavavel.
Blade::setContentTags('<%', '%>'); // for variables and all things Blade
Blade::setEscapedContentTags('<%%', '%%>'); // for escaped data
Add that into a common file, such as routes.php
.
Update your references from {!!
to <%
and !!}
to %>
.
Edit:
If you would instead like to do this on the AngularJS side, you can with adding this into your app.js
file (credits: scotch.io).
var sampleApp = angular.module('sampleApp', [], function($interpolateProvider) {
$interpolateProvider.startSymbol('<%');
$interpolateProvider.endSymbol('%>');
});
Replace the module name with your project's app module name.
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM