for your question, I think you need something like this: http://plnkr.co/edit/gp0zIwnj9Oz3IpQPXhDI?p=preview
I added data to the scope of your directive, this data is transmitted from the controller
scope: { ngModel: '=', somedata:'@' },
HTML:
<data-ng-pt-header somedata='{{somedata}}'></data-ng-pt-header>
And in the controller:
$scope.somedata='This comes from the controller';
and of course in the template:
<div class="well info-card days-left"> <legend>Spent</legend> <span>{{somedata}}</span> </div>
This is one of the many ways to pass data to a directive, which is easiest if you want more information about the directives, there is this great post: http://amitgharat.wordpress.com/2013/06/08/the-hitchhikers-guide -to-the-directive /
For the other two questions, yes, it would be nice to send the data to the directive from the controller, it greatly depends on the data and logic that you need, but your application seems to need it.
The best solution does not exist (at least not having just one simple example), but it seems to be a simple data exchange, the easiest way seems to fit your requirements;)
Good luck
source share