Reputation: 1384
I am using Laravel and AngularJS for my project. I changed the Angular curly brackets to {[{
because of, blade uses the same. I got some data with an $http.post()
in AngularJS and I want to print this data in my views, witch I have made in Laravels blade. Because of, I am printing data from AngularJS I am using ng-repeat:
<tr ng-repeat="school in data.result">
<td><a href="{{ URL::to('scholen/bekijk/') }}">{[{ school.name }]}</a></td>
<td>{[{ school.brin }]}</td>
<td>{[{ school.city }]}</td>
<td>{[{ school.phonenumber }]}</td>
</tr>
This works fine. The problem is: how can I print an value inside {{ URL::to('scholen/bekijk/') }}
?
Something like:
{{ URL::to('scholen/bekijk/'. {[{ school.id}]}) }}
I tried a lot, but I got errors only ;)
Upvotes: 0
Views: 1039
Reputation: 1099
I suggest don't mix angular and blade...
Look at this: https://github.com/Ferticidio/UPEnews/blob/master/app/views/indexangular.blade.php only load angular...
and: https://github.com/Ferticidio/UPEnews/tree/master/public In public i push all the angular logic...
This was very fast and comprensive for me..
Upvotes: 0
Reputation: 758
You should really pick one and stick with it, by that I mean don't try and mix Blade and Angular. If you want to go with Angular pages, then make them all Angular, not some kind of Blade-Angular hybrid.
When working with Angular and Laravel I completely remove any view logic from Laravel, and use it purely as the back-end logic. Angular is responsible for all the view templating and rendering.
Upvotes: 0
Reputation: 21901
that is because
{{ URL::to('scholen/bekijk/'. {[{ school.id}]}) }}
this code is interpret by php. but the syntax is incorrect acceding to php. because php accepts {[{ school.id}]})
part as a interpret-able php thing but its not. if u can put {[{ school.id}]})
inside the string then php is not going to interpret is because its know its just a string
. but in angular side angular knows that's is a something that angular should do because the string includes {[{ school.id}]})
.
so u can try something like,
{{ URL::to('scholen/bekijk/{[{ school.id}]})' }}
Upvotes: 1
Reputation: 2461
Something like:
{{ URL::to('scholen/bekijk/'. {[{ school.id}]}) }}
Why? Blade is processed with PHP, which is server-side.
AngularJS processes client-side, once any/all Blade processing is completely finished.
Upvotes: 1