简体   繁体   English

angularjs在选择更改事件上提交表单

[英]angularjs submit form on select change event

I'm using django in the back-end. 我在后端使用django。 I need to submit a form with a language parameter and refresh the page to change the language in the front-end. 我需要提交一个带有language参数的表单,并刷新页面以更改前端的语言。

I've got a select tag which is nested inside a form. 我有一个嵌套在表单中的选择标签。

<form>
   ...
   <select name="language" ng-model="selectedLanguage" ng-options="language in languages" ng-change="changeLanguage()">
   ...
</form>

I'd like to submit the form on select change event, what's the best way to do it with angularjs? 我想在选择更改事件上提交表单,使用angularjs的最佳方法是什么?

The $event object is not available for the change event (angular 1.3.0). $event对象不可用于更改事件(角度1.3.0)。

Have a $scope.$watch for selectedLanguage and call the submit function whenever it changes. 有一个$scope.$watch来查看selectedLanguage并在更改时调用submit函数。

Edit 编辑

In case you want to do form submit 如果您要提交表单

you can use angular.element.find to find your form. 您可以使用angular.element.find查找表格。 ( But im not sure why you need angular in case you are making a form submit) (但是我不确定为什么要提交表单时为什么需要角度)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM