我有类别页面,其中列出了所有产品及其表格。 例如
<div ng-repeat="product in products">
<form name="product[[ product.id ]]"></form> // [[]] custom angular syntax, result is product1,2,3
</div>
然后我有相同形式的产品页面。当我尝试应用相同的命名约定时
<form name="product[[ product.id ]]"></form>
这根本行不通。结果只是产品
。为什么它不接受这个名字?当我将其更改为其他内容时,例如coolName[[product.id]]
它有效(coolName1)。
这只是表现得很奇怪。另外 1 个指令(图像 jQuery slider ,应该等到 dom 加载)在该页面上对我不起作用。
有什么想法吗?
最佳答案
发生这种情况是因为在您的
<div ng-repeat="product in products"> <!-- product as repeater for products -->
<form name="product[[ product.id ]]"></form> <!-- product get's value from repeater -->
</div>
您必须更改 ng-repeat="something in products"
或
将表单名称更改为<form name="something[product.id]">
关于javascript - angular.js - 命名表单不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31024890/