I
I
Ivan Kondratiev2015-06-04 16:16:53
symfony
Ivan Kondratiev, 2015-06-04 16:16:53

Angular and Symfony2, what is this error?

I'm learning to make applications on symfony2 and angular. Faced with an error, I don’t understand what’s the matter, tell me.
app.js

'use strict';

var adminApp = angular.module('adminApp', ['ngRoute','adminControllers'])
    .config(['$routeProvider','$locationProvider','$httpProvider',
        function($routeProvider,$locationProvider,$httpProvider){

            $httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

            $locationProvider.html5Mode({
                enabled: true,
                requireBase: false
            });

            $routeProvider.when('/app_dev.php/admin/add-page', {
                templateUrl: '/app_dev.php/admin/add-page',
                controller: 'AddPageCtrl'
            });

            $routeProvider.when('/app_dev.php/admin/login', {
                templateUrl: '/app_dev.php/admin/login',
                controller: 'LoginCtrl'
            });

        }
    ]);

controller :
'use strict';

var adminControllers = angular.module('adminControllers',[]);

adminApp.controller('AddPageCtrl',['$scope', '$http', '$route', '$location', '$templateCache' ,
    function($scope, $http,$route,$location, $templateCache){

        $scope.addPage = function(){
            console.log($scope);
        };

}]);

the form:
<form class="form add-page" name="addPage" novalidate="novalidate" method="post" {{ form_enctype(form) }}>
    <div id="pages">
        <div>
            <label for="pages_title" class="required">Название страници</label>
            <input type="text" id="pages_title" name="pages[title]" required="required" class="form-control" ng-model="pages.title">
        </div>
        <div>
            <label for="pages_category_page" class="required">Категория страници(для выподающего меню)</label>
            <input type="number" id="pages_category_page" name="pages[category_page]" required="required" maxlength="10" class="form-control" value="0" ng-model="pages.category_page">
        </div>
        <div>
            <label for="pages_smallDescription" class="required">Краткое описание</label>
            <textarea id="pages_smallDescription" name="pages[smallDescription]" required="required" class="form-control" ng-model="pages.smallDescription"></textarea>
        </div>
        <div>
            <label for="pages_description" class="required">Полное описание</label>
            <textarea id="pages_description" name="pages[description]" required="required" class="form-control" ng-model="pages.description"></textarea>
        </div>
        <input type="hidden" id="pages__token" name="pages[_token]" value="xxxxxxxxxxxxxxxxxxx"></div>
    <div class="form-group">
        <br>
        <input type="submit" class="btn btn-default" ng-click="addPage(pages,addPage)" value="Добавить">
    </div>
</form>

when ng-click gives the following error
prntscr.com/7d0uh2

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Kononenko, 2015-06-04
@inik23

What's with the strange call outside attributes?
{{ form_enctype(form) }}

M
Mikhail Osher, 2015-06-04
@miraage

You are using the twig template engine. AngluarJS has the same parser markers.
See the "example" section below.
https://docs.angularjs.org/api/ng/provider/$interp...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question