Having trouble with a directive I'm building. I want to define options within the directive, but set a default option in my controller. The rendering looks good, but the default option isn't being selected. Any suggestions? Check out the Plunkr
angular.module('app', [])
.controller('Ctrl', function ($scope) {
$scope.defaultSearchRange = 3;
})
.directive('dateRange', function () {
return {
restrict: 'A',
scope: {
searchRange: '='
},
replace: true,
template: '<div><select ng-model="searchRange"><option ng-repeat="option in options" value="{{option.value}}">{{option.name}}</option></select></div>',
controller: function ($scope) {
$scope.options = [
{ name: '', value: 0 },
{ name: 'Today', value: 1 },
{ name: 'Yesterday', value: 2 },
{ name: 'Last 7 Days', value: 3 },
{ name: 'Last 30 Days', value: 4 },
{ name: 'Month to Date',value: 5 },
{ name: 'Year to Date', value: 6 }
]
}
}
})