Monday 20 February 2017

Step to use AngularJS and Laravel Blade together

In this article I will show you how to use AngularJS and Laravel Blade together.
People who have been using AngularJS for a while may know of this solution. However if you are just getting started or have never used Angular with a templating engine like Blade, read ahead!

The problem

When it comes to making AngularJS and Laravel Blade work together, there is only one real problem. Both AngularJS and Laravel Blade use double curly brackets for opening and closing tags. Luckily there is a quick and painless solution for this problem!

The solution

The solution for making AngularJS and Laravel Blade work together is simple. We can simply use Angular’s $interpolateProvider to change the tags.
In short: we want to change the tags of AngularJS to anything other than double curly brackets, for example a double percentage sign.
Example code would be:
var customInterpolationApp = angular.module(‘customInterpolationApp’, []);
customInterpolationApp.config(function($interpolateProvider) {$interpolateProvider.startSymbol('%%');