簡體   English   中英

角度預選

[英]Angular pre-selected

我有一個可以編輯的模態。 但是在我的模態中,我無法預選。

這是我的HTML

<select ng-model='names.productionType' ng-options="data for data in productionType"></select>

這是我的劇本

$scope.productionType =[
  "Article LP Composition",
  "Normal LP Composition",
  "Reading Material",
  "Transcribed Manuscript",
  "LP Production"
];

到目前為止,這是我嘗試過的

的HTML

<select ng-model='editable.productionType' ng-options="data for data in productionType" ng-selected="editable.productionType='{{names.production_type}}'"></select>

在我的劇本中

$scope.names.productionType = "Normal LP Composition";

它會預先選擇,但問題是我無法選擇其他選項

您應該首先聲明$scope.names ,然后向其添加productionType屬性。

 <select ng-model='names.productionType' ng-options="data as data for data in productionType">
  </select>

$scope.names ={};
$scope.names.productionType = "Normal LP Composition";

 var app = angular.module('plunker', []); app.controller('MainCtrl', function($scope) { $scope.productionType = [ "Article LP Composition", "Normal LP Composition", "Reading Material", "Transcribed Manuscript", "LP Production" ]; $scope.names = {}; $scope.names.productionType = "Normal LP Composition"; }); 
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/angular-filter/0.4.7/angular-filter.js"></script> <div ng-app="plunker" ng-controller="MainCtrl"> <select ng-model='names.productionType' ng-options="data as data for data in productionType"> </select> {{names.productionType}} </div> 

嘗試這個:

<select ng-model='names.productionType' ng-value="data.productionType" ng-options="data.productionType for data in productionType"></select>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM