각도 선택 목록을 선택 목록과 레이블을 함께 그릴 수있는 간단한 지시문으로 래핑하려고합니다.사용자 정의 AngularJS 지시문이 제대로 그려지지 않습니다.
두 가지 문제가 있습니다.
1. 선택 목록 옵션은 내가 내 지시 태그 속성에 나타내는 데이터로 채워지지 않는 나의 지시로 아래로 통과하려고
2. ngModel 속성을 채우기되지 않습니다.
var myApp = angular.module('myApp',[]);
myApp.controller('Ctrl', ['$scope', function($scope){
$scope.currentBusinessStructure = '';
$scope.businessStructure = ['Monarchy', 'Corporation'];
}]);
myApp.directive('specialSelect', [function(){
return {
restrict: 'A',
transclude: true,
template:
'<label ng-transclude></label> \
<select ng-model="currentBusinessStructure" ng-options="{{ngOptions}}" class="form-control"> \
</select> \
<br>INSIDE MY DIRECTIVE: {{ngModel}} : {{ngOptions}}',
scope: {
ngOptions: '@ngOption',
ngModel: '='
}
};
}]);
: '= ngOption'없이 @ – Scott
죄송합니다. 완전히 잘못 읽었습니다. 귀하의 ngOptions 표현이 잘못되었다고 생각합니다. 내가 믿는 완전한 표현이 필요해.이 문서를 확인해. https://docs.angularjs.org/api/ng/directive/select – Scott