简体   繁体   中英

Blade templating with angular2 templating?

I have problem because im using angular with laravel.I added this in routes.php

Blade::setContentTags('<%', '%>');        // for variables and all things Blade
Blade::setEscapedContentTags('<%%', '%%>');   // for escaped data

But its not working because im getting an error when i display data from angular. Any suggestion how can i fix this?

For example if i say:

{{'test'}} it works but if i say {{response.test}} where response is from angular i get an error because laravel thinks that is his.

Blade will ignore anything preceded by the @ character. Try that.

first confing laravel blade and angular js

<script type="text/javascript">
var app = angular.module('myApp', []) 
  .config(function($interpolateProvider) {
    $interpolateProvider.startSymbol('<%=');
    $interpolateProvider.endSymbol('%>');
  });
</script>

write your angular code like this

<%= cs.Category_name %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM