I am using Laravel 4.2 for an old app. It is mixed with Angular. I need to display a map of locations returned from Laravel.
I am using an Angular directive on a blade
template to do this.
I need to pass Laravel values into the directive so they can be used. I saw you can pass an array in this question, but am not sure how to do it with Laravel blade values.
Note: Since blade uses {{ }}
for interpolation, I have told Angular to change its interpolation:
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
Laravel blade template: $locations
is a blade
variable:
<fz-map locations="{{$locations}}"></fz-map>
Directive:
( function( ng, app ) {
'use strict';
app.directive( 'fzMap', ['$rootScope', function($rootScope) {
return {
restrict: 'AE',
scope : {
locations : '='
},
link: function(scope, element, attr) {
console.log('loc', scope.locations);
scope.Template = '/directive_html/map.html';
},
template: "<div ng-include='Template'></div>"
};
} ]);
} )( angular, myApp );
Angular error: Unexpected end of expression: [{