AngularJS, Angular Material 与 Symfony 3 结合

首先需要在父级模版中引入 AngularJSAngular Material.

<link rel="stylesheet" href="{{ asset('angular-material.css') }}">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=RobotoDraft:300,400,500,700,400italic">

<script src="{{ asset('angular.js') }}"></script>
<script src="{{ asset('angular-aria.js') }}"></script>
<script src="{{ asset('angular-animate.js') }}"></script>
<script src="{{ asset('angular-material.js') }}"></script>
`</pre>

在js文件中,写入:

<pre>`angular.module('myApp',['ngMaterial'])
    .config(function($interpolateProvider){
        $interpolateProvider.startSymbol('{[{').endSymbol('}]}');
})
    .controller('myController', myController);

myController.$inject = ['$scope'];

function myController( $scope ) {

}`</pre>

最后,在twig模版中写scope变量时,需要写成:

<pre>`{[{ scopeVariable }]}

参考内容: