I would like to create a directive with a dropdown template. I try to give the value for ng-options as a parameter of the directive but the dropdown only contains the default value.
I don't understand with my dropdown is empty if I use the directive.
Here is a Fiddle and my code in this post : http://jsfiddle.net/wXV6Z/6/
var app = angular.module('app', []); function Ctrl($scope){ $scope.countries = [ algeria={name:'ALGERIA', phoneCode:'213'}, andorra={name:'ANDORRA', phoneCode:'376'}, angola={name:'ANGOLA', phoneCode:'244'} ]; } app.directive('skiTest', function() { return { 'replace': true, 'restrict': 'E', 'scope': { 'data': '=', }, link: function (scope, element, attrs) { scope.options = attrs.selectOptions; }, 'template':'<div><select name="testSelect" ng-model="ngModel" ng-options=" {{options}} in data"><option value="">Code</option></select></div>' } });
<div ng-controller="Ctrl">
<div>
<h2>Without directive</h2>
<select ng-model="code" ng-options="country.phoneCode as country.name for country in countries">
<option value="">Code</option>
</select>
</div>
<div>
<h2>With directives</h2>
<ski-test data="countries" select-options="country.phoneCode as country.name for country"></ski-test>
</div>
--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/oFx0rTTp3eA/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
--