angularjs - angular directive scope: setting a default value -
i'm creating datepicker directive, part of markup is:
<select class="form-control" ng-model="day" ng-options="day.nr day in alldays">
i'm trying define alldays
in scope
attribute this:
ehrapp.directive('datepicker', function() { homecoming { scope: { alldays: [ {'nr': 1}, {'nr': 2}, {'nr': 3}, (...) {'nr': 31} ] },
but doesn't work, fails "typeerror: undefined not function".
any ideas how accomplish this?
you defining value within scope
attribute of directive configuration, you'd define isolate scopes directive uses. instead of doing there, either in link
function or in controller
function:
return { link : function (scope, element, attrs) { scope.alldays = [{nr : 1}]; } }
or
return { controller : function ($scope, $element) { $scope.alldays = [{nr : 1}]; } }
angularjs angularjs-directive angularjs-scope
No comments:
Post a Comment