angular.js中的html选项如何正确ng如果?

时间:2016-01-07 12:13:54

标签: javascript angularjs

我在控制器中有范围:$scope.readOnly = true 然后我在html中有代码:

  <select ng-if="readOnly" ng-model="readOnly" required>
     <option value="true" selected>True</option>
     <option value="false">False</option>
  </select>

 <select ng-if="!readOnly" ng-model="readOnly" required>
     <option value="true">True</option>
     <option value="false" selected>False</option>
 </select>

<button ng-click="save()"> Save</button>

但它不能正常工作:/点击保存,结果未定义:/如何使其正确?

1 个答案:

答案 0 :(得分:1)

尝试以这种方式执行此操作:

        function generateTable2($associative_array){
        echo '<table width="620" class="optimization_table" border="1"  cellspacing="0" cellpadding="0"><thead><tr><th colspan=2>';
        echo implode('</th><th colspan=2>', array_keys(current($associative_array)));
        echo '</th></tr></thead><tbody>';
        foreach ($associative_array as $row=>$value){
            echo "<tr>";

            if(is_array($value)) {
                foreach($value as $value2) {
                    if(is_array($value2)) {
                        foreach($value2 as $value3) {
                            echo "<td>$value3</td>\n";
                        }
                    }
                    else {
                        echo "<td colspan=2>$value2</td>\n";
                    }

                }
            }
            else {
                echo "<td colspan=2>$value</td>\n";    
            }

            echo "</tr>";

        }
        echo '</tbody></table>';
        }

Example