以下是我的一個JS需要從一個JS訪問數組到其他
var ruleField = [
{
id: "T1",
datastore: "",
table: "SENSORS",
columns: ["SNS_ID","HOST_ID","SESSION_ID"],
tableHeaders: ["SNS ID","HOST ID","SESSION ID"]
}
];
在另一個JS我需要訪問列陣列中的下拉選項
<select name="child.KEY_NAME" ng-if="child.KEY_NAME != 'Host' && child.KEY_NAME != 'Sensor' && child.KEY_NAME != 'Operator' && child.KEY_NAME != 'Value'" class="form-control" ng-model="temp.condition[$index][child.KEY_NAME]"" ng-disabled="readonly" ng-change="selectedOption1(selectAction);displayActionParam()">
<option ng-repeat="field in ruleField.columns track by $index" value= "{{ field }}" >{{ field }}</option>
</select>
ruleField是一個數組,因此您需要通過索引ruleField [0] .columns –
來訪問它。您可能需要分配'window.ruleField =',或根據您的上下文將其包含在'$ scope'中 – slezica