javascript - How to pass evaluated values to a custom element directive? -


i have custom element directive following template:

<div>    <input value="{{datafromrootscope}}" /> </div> 

and definition:

dirmodule.directive('mydirective', function() {         return {             restrict: 'e',                         templateurl: '/scripts/app/directives/mydirective.html'              };     } ); 

i use directive shown below:

<my-directive my-value="{{datafromscope}}"></my-directive> 

i.e. want use evaluated datafromscope value inside custom directive datafromrootscope. how can reach this?

you can use '@' sign :

dirmodule.directive('mydirective', function() {     return {         scope: { myvalue: '@' },         restrict: 'e',                     templateurl: '/scripts/app/directives/mydirective.html'          }; }); 

the '@' sign binds evaluated value of dom attribute directive.

you can use directive asked :

<my-directive my-value="{{datafromscope}}"></my-directive> 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -