简体   繁体   English

将Flexslider与Angular.JS一起使用

[英]Use Flexslider with Angular.JS

I try to manage a responsive slider with Flexslider on the front part of a website, But as I am working with Angular.js, my images does not have directly a "src" attribute specified, and Angular manage it itself with the "ng-src" attribute. 我尝试使用网站前端的Flexslider管理响应式滑块,但是当我使用Angular.js时,我的图像没有直接指定“ src”属性,而Angular本身通过“ ng- src”属性。 And so my slider works (I can see the navigation controls), but is blank... 因此,我的滑块可以工作(我可以看到导航控件),但是它是空白的...

Any way to fix it ? 有什么办法解决吗? Or another responsive slider library idea, that should work with Angular.js ? 还是应该与Angular.js一起使用的另一个响应式滑块库想法?

#templates/detail.html
<div class='flexslider'>
    <ul class='slides'>
        <li ng-repeat='slide in project.slides'><img ng-src='{{slide}}' alt='{{project.name}}' /></li>
    </ul>
</div>

#js/app.js
'use strict';

angular.module('test', []).config([
    '$routeProvider',
    function ($routeProvider) {
        $routeProvider
            .when('/', { templateUrl: 'detail.html', controller: ProjectCtrl })
    }
]);

#js/controllers.js
'use strict';

function ProjectCtrl($scope) {
    $scope.project = {
        id: 1,
        name: 'Test',
        slides: [
            'test.png',
            'test2.png'
        ]
    };
$('.flexslider').flexslider();
};

In fact it was caused by the Twig render engine, that users the double brackets too: {{ }} 实际上,这是由Twig渲染引擎引起的,该用户也使用了双括号:{{}}

I fixed it by rendering some raw HTML using the raw filter of twig : http://twig.sensiolabs.org/doc/filters/raw.html 我通过使用twig的原始过滤器呈现一些原始HTML来修复它: http : //twig.sensiolabs.org/doc/filters/raw.html

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

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