在Symfony2中集成Angular JS

时间:2014-12-16 10:59:09

标签: angularjs symfony

我尝试将angularJS集成到Symfony2中,但我遇到了一些困难 您可以在下面找到base.html.twig页面的代码和我的页面app.js的代码

<html lang="fr" ng-app="routeApp">
<head>
    <meta charset="UTF-8" />
    <title>
        {% block title %}
            Accueil !
        {% endblock %}
    </title>
    {% block stylesheets %} 
        <link rel="stylesheet" href="{{ asset('bundles/ardbackend/components/bootstrap/dist/css/base-admin.css') }}" type="text/css" />
        <link href="{{ asset('bundles/ardbackend/components/bootstrap/dist/css/bootstrap.min.css') }}" rel="stylesheet" type="text/css"/>
        <link href="{{ asset('bundles/ardbackend/components/bootstrap/dist/css/bootstrap-responsive.min.css') }}" rel="stylesheet" type="text/css"/>  
        <link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
    {% endblock %}
    {% block javascripts %}
        <script src="{{ asset('bundles/ardbackend/components/angular/angular.min.js') }}"></script>
        <script src="{{ asset('bundles/ardbackend/components/angular/angular-route.js') }}"></script>
        <script src="{{ asset('bundles/ardbackend/components/angular/app.js') }}"></script>
        <script src="{{ asset('bundles/ardbackend/bootstrap/dist/js/bootstrap.min.js') }}"></script>
        <script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script>
        <script src="{{ path('fos_js_routing_js', {"callback": "fos.Router.setData"}) }}"></script>
    {% endblock %}
</head>
<body>
    <div ng-view>
    <nav>
        <a href="#/login" class="btn btn-primary">Page d'accueil</a>
        <a href="#/" class="btn btn-success">Page de contact</a>
    </nav>
        {% block body %}
        {% endblock %}
    </div>
</body>

这是我的app.js

'use strict';


/**
 * Déclaration de l'application routeApp
 */
var routeApp = angular.module('routeApp', [
    // Dépendances du "module"
    'ngRoute'
]);

/**
 * Configuration du module principal : routeApp
 */
routeAp

p.config(['$routeProvider',function($routeProvider) { 

    // Système de routage
    $routeProvider
    .when('/login', {
        templateUrl: Routing.generate('login'),
        controller: SecurityController
    })
    .when('/', {
        templateUrl: Routing.generate('pour_test'),
        controller: DefaultController
    })
    .otherwise({
        redirectTo: '/login'
    });
}]);

我不明白,我的代码中缺少哪些内容才能使其正常工作 有什么帮助吗?

1 个答案:

答案 0 :(得分:0)

尝试更改角度中的开始和结束符号,因为我理解它与相同的符号

冲突
   customInterpolationApp.config(function($interpolateProvider) {
    $interpolateProvider.startSymbol('//');
    $interpolateProvider.endSymbol('//');
  });;