简体   繁体   English

Laravel-使用Angular动态添加图像

[英]Laravel - Add dynamically image with Angular

I want to input image's src value with Angular. 我想用Angular输入图像的src值。 Here is my code : 这是我的代码:

HTML : HTML:

<div ng-app="myApp" ng-controller="MyCtrl">
   <img src="{{asset('assets/img/'.'/'.  @{{ item.name }} )}}">
</div>

JS : JS:

var app = angular.module('myApp', []);
app.controller('MyCtrl', function($scope, $http) {
    $scope.items =
    [
            {
                sort: 1,
                name: 'name1',
                img : 'mezon1',

            },
                {
                sort: 1,
                name: 'name2',
                img : 'mezon2',

            }

    ]
 }
});

But it's not working and Laravel gives me this error : FatalErrorException .. unexpected '{' 但是它不起作用,Laravel给了我这个错误: FatalErrorException ..意想不到的'{'

Any suggestion? 有什么建议吗?

chenge it to 追求它

<div ng-app="myApp" ng-controller="MyCtrl">
   <img src="{{asset('assets/img/')}}@{{ item.name }}">
</div>

Angular and blade (laravel template engine) are conflicting on the use of "{" and "}". 角和刀片(laravel模板引擎)在使用“ {”和“}”时发生冲突。 You should configure the one or the other to use another interpolation characters. 您应该将一个或另一个配置为使用另一个插值字符。

Have a look on https://scotch.io/tutorials/quick-tip-using-laravel-blade-with-angularjs 看看https://scotch.io/tutorials/quick-tip-using-laravel-blade-with-angularjs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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