我在symfony2中創建了表單,最後呈現按鈕提交表單。當我添加ng-app="myApp"
一切正常,但我無法提交此頁上的表單。爲什麼是這樣以及如何解除這個問題?AngularJS塊以symfony2的形式提交按鈕
FORM:
->add('company','choice',array(
'mapped' => false,
'attr'=>array('ui-select2'=>'myArray', 'ng-model'=>'form.company','ng-options'=>'option.value as entity.name_company for entity in entities','ng-change' => 'changeItem()')
))
->add('project',null,array(
'attr'=>array('ui-select2'=>'myArray2', 'ng-model'=>'form.task','ng-options'=>'option.value as entity.description_task for entity in tasks')
))
VIEW:
<html ng-app="flowApp">
<head>
<link rel="stylesheet" href="{{ asset('external-libs/select2/select2.css')}}">
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="{{ asset('external-libs/select2/select2.js')}}"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.5/angular.min.js"></script>
<script src="{{ asset('external-libs/select2.js')}}"></script>
<script src="{{ asset('external-libs/app.js') }}"></script>
<style>
.select2-choice { width: 220px; }
</style>
</head>
<body>
<div class="container" ng-controller="MainCtrl">
{{ form(form) }}
</div>
</body>
</html>
SCRIPT:
var app = angular.module('flowApp', ['ui.select2']).config(function($interpolateProvider){
$interpolateProvider.startSymbol('{[{').endSymbol('}]}');
}
);
app.controller('MainCtrl', function ($scope, $element,$http) {
$http({method: 'GET', url: 'companies.json'}).
success(function(data, status, headers, config) {
$scope.entities = data.entities;
$scope.form = {company: $scope.entities[0].value };
console.debug(data.entities);
});
});
你可以添加一些代碼嗎?你在這裏用什麼角度? – GonchuB
是的,我正在使用select2腳本進行填充選擇。我添加了代碼。 – mmmm
好的。首先。 $ scope.forms是一個變量,你將它作爲一個函數調用(爲什麼你要做'{{form(form)}}??「)。否則,您是否看到GET請求的網絡流量? – GonchuB