directive: specify default val for optional attribute?

53 views
Skip to first unread message

Nikita Tovstoles

unread,
Jan 17, 2014, 11:32:07 AM1/17/14
to ang...@googlegroups.com
I have a directive with refreshInterval attribute. I would like to make that attribute optional ('@?') but fallback to a default value if one is not provided. Is there a scope syntax for the latter ie something like:
scope: { refreshInterval : '@?:10' }

...or do I just use:
scope: { refreshInterval : '@?' }

...and then check whether $scope.refreshInterval is defined in link() or controller() and - if not - assign to '10' there?

thanks,
-nikita

Sam Pepose

unread,
Jan 18, 2014, 3:31:21 PM1/18/14
to ang...@googlegroups.com
You will have to do the latter.

Nikita Tovstoles

unread,
Jan 18, 2014, 4:25:15 PM1/18/14
to ang...@googlegroups.com

Thx

--
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/i4VvzEs2YLs/unsubscribe.
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.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages