你們中的任何一位紅色文檔?
<label>Check me to select: <input type="checkbox" ng-model="selected"></label><br/>
<select aria-label="ngSelected demo">
<option>Hello!</option>
<option id="greet" ng-selected="selected">Greetings!</option>
</select>
NG-選擇= '選擇' < - 字撇點選擇$ scope.selected。把你的選擇值放在那裏。
這裏有文檔鏈接:ngSelected
這裏有我的例子。 我給你帶來了我的整個JavaScript閱讀4從數據庫中選擇依賴於對方的選擇,在此之後,你會看到我的整個玉代碼的一部分。你可以用你的名字複製這個溶劑。
.controller('datatableRelationController', ['$scope', '$http',
function ($scope, $http) {
$scope.relations = [];
$scope.tables = [];
$scope.firstTableColumns = [];
$scope.secondTableColumns = [];
//display menu with tables
$http.get('/api/datatable/list/')
.success(function (json_data, status, headers, config) {
for (key in json_data) {
var fields = json_data[key]['fields'];
$scope.tables.push({name: fields['name']});
}
})
.error(function (data, status, headers, config) {
Materialize.toast("Błąd pobierania tabel", 2000);
});
$scope.addRelation = function() {
var data = {
source_table: $scope.firstTable.name,
source_column: $scope.firstTableSelectedColumn.name,
dest_table: $scope.secondTable.name,
dest_column: $scope.secondTableSelectedColumn.name,
relation_type: 'normal'
};
apiPOST('/api/relation/add/', data, $http)
.success(function (data, status, headers, config) {
Materialize.toast('Relacja dodana.', 2000);
$scope.relations = [];
$scope.tables = [];
$scope.firstTableColumns = [];
$scope.secondTableColumns = [];
})
.error(function (data, status, headers, config) {
Materialize.toast('Błąd dodawania relacji.', 2000)
});
};
var getColumns = function (tableName, destination) {
$http.get('/api/worktable/fields/get/' + tableName)
.success(function (json_data, status, headers, config) {
var fields = json_data[0];
for (key in fields) {
destination.push({name: fields[key]});
}
})
.error(function (data, status, headers, config) {
Materialize.toast("Błąd pobierania kolumn z tabeli", 2000);
});
}
$scope.firstTableChange = function (firstTable) {
getColumns(firstTable.name, $scope.firstTableColumns);
};
$scope.secondTableChange = function (secondTable) {
getColumns(secondTable.name, $scope.secondTableColumns);
};
}
]);
JADE部分:
.row
.col.l5.m6.s12.offset-l1
.form
.input-field
select.browser-default(ng-model="firstTable", ng-change="firstTableChange(firstTable)", ng-options="table.name for table in tables", material-select)
option(value="", disabled, ng-selected) Wybierz pierwszą tabelę
div(ng-show="firstTable || secondTable")
.form(ng-show="firstTable")
.input-field
select.browser-default(ng-model="firstTableSelectedColumn", ng-change="firstTableSelectedColumn", ng-options="column.name for column in firstTableColumns", required, material-select)
.col.l5.m6.s12
.form
.input-field
select.browser-default(ng-model="secondTable", ng-change="secondTableChange(secondTable)", ng-options="table.name for table in tables", material-select)
option(value="", disabled, ng-selected) Wybierz drugą tabelę
div(ng-show="firstTable || secondTable")
.form(ng-show="secondTable")
.input-field
select.browser-default(ng-model="secondTableSelectedColumn", ng-change="secondTableSelectedColumn", ng-options="column.name for column in secondTableColumns", required, ng-show="secondTable", material-select)
.row
.col.s12.center-align
button.btn.orange.lighten-2.weaves-effect.white-text(ng-click="addRelation()") Zastosuj
我想你誤解了我的問題。 – Chrillewoodz