How can AngularJS observe attributes on a custom directive to bind Angular values?
Here is my current progress:
<tile title="Sleep Duration" data-value="{{sleepHistory.averageSleepTime}}"/>
app.directive('tile', [function() {
return {
restrict: 'E',
link: function(scope, element, attrs) {
var title = attrs.title;
attrs.$observe('dataValue', function(val) {
var data = val;
console.log(data);
var dom =
"<div>" +
"<p>" + title + "</p>" +
"<p>" + data + "</p>" +
"</div";
$(element).append($(dom.trim()));
});
}
};
}]);
However, the observed value is returning as undefined