Pregunta

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. 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 ?

#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();
};
¿Fue útil?

Solución

In fact it was caused by the Twig render engine, that users the double brackets too: {{ }}

I fixed it by rendering some raw HTML using the raw filter of twig : http://twig.sensiolabs.org/doc/filters/raw.html

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top