custom AngularJS Directive won't draw properly -
i trying wrap angular select list simple directive allow me draw select list , label both together.
i encountering 2 problems.
1.the select list options not populating
2.the ngmodel attribute try pass down directive not populate data indicate in directive tag attribute.
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 directive: {{ngmodel}} : {{ngoptions}}', scope: { ngoptions: '@ngoption', ngmodel: '=' } }; }]);
please check out fiddle here
try this, finally. sorry didn't first.
<select ng-model="ngmodel" ng-options="label label in ngoptions" class="form-control">
and div should be
<div special-select ng-model="currentbusinessstructure" ng-option="businessstructure">how business structured?</div>
Comments
Post a Comment