Hello,
I work on a Directive and wonder if I can access a controller using the
require property. Currently I have no luck with this setup, I wondre what
I'm doing wrong...
<div
class="timeline"
ng-controller="TimelineController"
tl-edit
tl-years min="500" max="2010" step="50">
In the controller 'TimelineController' I want to have access to the values
from attributes min ("500") max ("2010") and step ("50")
I try doing that via a Directive since that has direct access to attributes
using the attrs param in link(). (Q: If there's an easier way please let me
know!)
I want the Directive tl-edit to have access to TimelineController in order
to inject values of attrs. I do is this
app.directive('tlYears',function(){
function link(scope,element,attrs,TimelineController){
TimelineController.init({
timelineWidth: element.attr('width'),
startYear: attrs.min,
endYear: attrs.end,
step: attrs.step
})
}
return{
restrict: 'A',
link: link,
require: 'ngController'
}
require: 'ngController'
refers to Directive ng-controllre, give me some kind of generic object. If
I call TimelineController.init() I gte an error "
TimelineController.init is not a function" while TimelineController. contains
function init()...
What to do here?
Thanks,
Marc
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.