更新到 1.2 后,带有变量的表单操作无效 [英] Form action with variable not valid after update to 1.2
问题描述
我在以前的 AngularJS
版本中使用以下代码生成了一个表单操作:
I was generating a form action in my previous version of AngularJS
using this code:
<form action="{{ api }}/products/image">
然而,我刚刚更新,现在显然太松了.
However, I just updated and now that apparently is too loose.
插入时出错:{{ api }}/products/image严格上下文转义不允许在需要可信值时连接多个表达式的插值.
Error while interpolating: {{ api }}/products/image Strict Contextual Escaping disallows interpolations that concatenate multiple expressions when a trusted value is required.
如何在 1.2.4
中实现相同的功能?
How do I achieve the same functionality in 1.2.4
?
推荐答案
从 Angular 1.2.x 开始,你可以仅将一个表达式绑定为 URL.
Since Angular 1.2.x, you can bind only one expression as URL.
因此,在您的控制器上,执行以下操作:
Hence, on your controller, do the following:
$scope.actionUrl = $scope.api + '/products/image';
在模板中:
<form action="{{ actionUrl }}">
更新
正如@Fourth 所建议的:
As suggested by @Fourth:
<form action="{{ api + '/products/image' }}">
这篇关于更新到 1.2 后,带有变量的表单操作无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!