0

I'm trying to use a bootstrap theme angularjs based in a symfony 2 project; i have a bundle with administration gui, so i have following situation:

Resources
    |
    |------public
    |         |
    |         |----css
    |         |      | ...
    |         |
    |         |----js
    |              |---- angular.js
    | 
    |------views

This theme use two angularjs templates (template1.html, template2.html). What is the best way to configure symfony to work with this theme?

2
  • could you clarify on what you want to configure? Commented Nov 30, 2014 at 18:20
  • I would like to know where is better put templates in project structure, for example under views. Than i don't know how to configure in the right way the symfony routes to work with angular templates. Commented Dec 1, 2014 at 6:15

2 Answers 2

2

After some test, i figure out a solution to my problem. i think that i good solution to use angular.js template inside a symfony bundle is put templates under bundle resources/public path and then control the output name generated from assetic using output parameter. For example:

Resources
    |
    |----public
    |       |
    |       |-----css
            |
            |-----js
            |
            |-----templates
            |         |
                      |-----dashboard.html

and in twig template:

{% javascripts '@AdminBundle/Resources/public/templates/dashboard.html' output='admin/templates/dashboard.html'%}
{% endjavascripts %}

So lauching assetic with:

php app/console assetic:dump

it will generate angularjs template (dashboard.html) under web/templates directory.

In this way angular templates are out of control of twig template engine and this point can be an advantage in some situations. I don't know if this is the best solution to my problem, but for shure it's consistent with angular.js and symfony logic.

Sign up to request clarification or add additional context in comments.

Comments

-1

Put the Angular template files directly to your web directory, as they dont need to be rendered by twig.

As for the routing, I understand that you want to leave the routing to AngularJS, so just create a symfony controller, which renders the index page for any given url like in this answer: Angular one page site dont work properly when enables $locationProvider.html5Mode(true);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.