2016-07-12 5 views
0

誰かが私の問題を理解するのを助けてくれることを願っています。私はいくつかの配列データでコンボボックスを埋めることを試みていますが、空のコンボボックスが表示されるために何も返されないようになっています。私は閉じていますが、見つからないものを見つけることができます。Angularjs - comboBoxを動的に入力する(Array())

は、あなたのangularjs参照が間違っているようだ

angular.module('demoApp', []) 
 
    .controller('simpleController', ['$scope', function($scope) { 
 
    $scope.employeeCollections = [ 
 
     { id:'1',name: 'Dave Jones', title: 'IT Administrator' }, 
 
     { id:'2',name: 'Daniel Thomas', title: 'Software Developer' }, 
 
     { id:'3',name: 'Sam Alexandrovic', title: 'Senior Software Developer' } 
 
    ]; 
 
    $scope.selectedEmployee = $scope.employeeCollections[0].name; 
 
    }]);
<html ng-app="demoApp"> 
 

 
<head> 
 
    <script src="Scripts/angular.min.js"></script> 
 
</head> 
 

 
<body> 
 
    <h1> Employee Information </h1> 
 

 
    <div class="container" ng-controller="simpleController"> 
 
    <select ng-model="selectedEmployee" ng-options="employee as employee.name for employee in employeeCollections"></select> 
 
    </div> 
 
</body> 
 

 
</html>

答えて

0

事前にありがとうございます。パスを確認してください。下記のCDNスニペットを参照してください。

<html ng-app="demoApp"> 
 
<body> 
 
<h1> Employee Information </h1> 
 

 
<div class="container" ng-controller="simpleController"> 
 

 
<select ng-model="selectedEmployee" ng-options="employee as employee.name for employee in employeeCollections"></select> 
 

 
</div> 
 
</body> 
 

 
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.7/angular.min.js"></script> 
 
<script> 
 

 
angular.module('demoApp', []) 
 
.controller('simpleController',['$scope', function ($scope) { 
 
    $scope.employeeCollections = [ 
 
     { id:'1',name: 'Dave Jones', title: 'IT Administrator' }, 
 
     { id:'2',name: 'Daniel Thomas', title: 'Software Developer' }, 
 
     { id:'3',name: 'Sam Alexandrovic', title: 'Senior Software Developer' } 
 
    ];    
 
    $scope.selectedEmployee = $scope.employeeCollections[0].name; 
 
    } 
 
    ] 
 
); 
 
</script> 
 
</html>

関連する問題