如何在Laravel Blade中实现AngularJS应用 [英] How to implement AngularJS app in Laravel Blade
问题描述
我需要实施以下操作: https://github.com/pshevtsov/flashcards 进入我的Laravel Blade看法.我尝试安装angular并链接刀片文件中的所有文件.但这不起作用,因为laravel和angular在文件中使用{{ }}
.
您可以设置自定义AngularJS花括号以防止与Blade模板引擎冲突:
var app = angular.module('app', [])
.config(function($interpolateProvider) {
// To prevent the conflict of `{{` and `}}` symbols
// between Blade template engine and AngularJS templating we need
// to use different symbols for AngularJS.
$interpolateProvider.startSymbol('<%=');
$interpolateProvider.endSymbol('%>');
});
我建议使用<%= %>
,因为它是常用的结构,您可以在下划线模板中找到它. /p>
之后,Angular代码将如下所示:
<li ng-repeat="phone in phones">
<p><%= phone.name %></p>
</li>
I need implement this: https://github.com/pshevtsov/flashcards into my Laravel Blade View. I tried to install angular and link all files in blade file. but it doesn't work, because laravel and angular use {{ }}
in files.
You can set custom AngularJS curly braces to prevent conflict with Blade template engine:
var app = angular.module('app', [])
.config(function($interpolateProvider) {
// To prevent the conflict of `{{` and `}}` symbols
// between Blade template engine and AngularJS templating we need
// to use different symbols for AngularJS.
$interpolateProvider.startSymbol('<%=');
$interpolateProvider.endSymbol('%>');
});
I suggest to use <%= %>
because it's the often used construction, you can find it in Underscore templates.
After that Angular code will look like this:
<li ng-repeat="phone in phones">
<p><%= phone.name %></p>
</li>
这篇关于如何在Laravel Blade中实现AngularJS应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!