I am currently facing challenges with data binding in AngularJs.
Within my .html file, I have the following markup that includes a custom directive:
<my-directive ng-repeat="i in object" attr-1="{{i.some_variable}}"></my-directive>
Important Note: The 'some-variable' value is updated every 10 seconds (based on the associated collection and passed to the template through the controller).
The code for the directive is as follows:
myApp.directive('myDirective', function () {
scope: {
'attr-1': '=attr1'
This results in an exception due to the brackets in attr-1 as shown in the html code above.
However, it functions correctly when using read-only access (noted with the at-sign below):
myApp.directive('myDirective', function () {
scope: {
'attr-1': '@attr1'
I utilize scope.attr-1 in the directive's HTML to display its value.
The issue lies in the fact that with read-only access, the UI fails to reflect any changes made to the attribute.
I came across a potential solution involving $parse or $eval, but I struggled to implement them. Are there better alternatives available?