邏輯:ng-if表單標籤內嗎?
if(condition)
Use first `<form ng-submit="action1">`
else
Use second `<form ng-submit="action2">`
在PHP的方法邏輯:
<?php
if(condition){
echo "<form action='action1.php' >";
}
else{
echo "<form action='action2.php' >";
}
echo "....many many many inputs here...";
echo "</form>";
?>
我試圖寫的是這樣的:(我使用AngularJs)
<form ng-submit="action1" ng-if="condition1"> ---> First condition
<form ng-submit="action2" ng-if="condition2"> ---> Second condition if first condition fails
....Many many many inputs
</form>
但是我當然可以簡單地寫下這樣的內容:(會是一種痛苦屁股)
<div ng-if="condition1"> ---> First condition
<form ng-submit="action1" >
....Many many many inputs
</form>
</div>
<div ng-if="condition2"> ---> Second condition if first condition fails
<form ng-submit="action2" >
....Same inputs as in the first div
</form>
</div>
我的問題是,是否有可能使用ng-if
(我也試過ng-disabled
)一<form>
標籤裏面?
我試圖避免的重新編碼所有我inputs
的form
裏面,如果我會讓唯一的變化是開放<form>
標籤。
我搜索了一個答案,沒有發現任何東西,唯一剩下的就是確認並詢問。
你可能可以做類似 '
你可以在ng-submit中使用表達式。嘗試'ng-submit =「{condition1?action1():condition2?action2():action3()}' – zcui93
第二種情況應該只是'!condition1' – FuzzyTree