javascript - Angular with {{}} directive attribute -


is there way pass {{string}} directive gets attribute $attrs (not $scope)?

here code:

controller:

... scope.someid = "someid"; ... 

html:

<my-dir id="{{someid}}"></my-dir> 

directive

app.directive('mydir', function() {    return {       controller: function($attrs){          console.log($attrs.id) //output: {{someid}}       }    } }) 

what want output someid , not {{someid}}.

you not able access value $attrs till initial digest cycle triggered. once digest cycle triggered, able access $attrs.

app.directive('mydir', function() {    return {       controller: function($attrs){          console.log($attrs.id) //output: {{someid}}          $attrs.$observe('id', function (newval, oldval) {              console.log(newval, oldval); // here able access evaluated value.           });       }    } }) 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -