2016-07-12 2 views
0

누군가 내 문제를 파악하는 데 도움이되기를 바랍니다. 나는 어떤 배열 데이터로 comboBox를 채우려고 노력하고 있지만 빈 comboBox를 표시하는 것은 아무것도 반환하지 않는 것처럼 보입니다. 나는 닫혀 있지만 내가 놓친 것을 찾을 수 있습니다. Angularjs - comboBox를 동적으로 채우기 (배열())

은 당신의 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>