0

i try to get data from controller to directive template using angular js. but it doesn't work..what's wrong with my code.

Directive template:

  <section class="col col-3 required">
       <code-input:select  ></code-input-select>
  </section>

Directive Code:

 gateApp.directive('codeInputSelect',function(){
    return{
        restrict : 'E',
        scope : {
            dtaas : '@'
        },
        template : '{{dtaas+ "uu"}}',
        link : function(scope, elem, attr){
        }
    }
})

My controller:

$scope.dtaas="hi welcome to ";
uday s
  • 291
  • 1
  • 2
  • 15

2 Answers2

0

You should do something like:

<section class="col col-3 required">
    <code-input-select dtaas="dtaas" ></code-input-select>
</section>
masimplo
  • 3,674
  • 2
  • 30
  • 47
  • in this way it's working fine..but i need to share data from controller to directive.? – uday s Sep 28 '15 at 07:25
  • you need to change the binging to two way in your directive declaration then like so: scope : { dtaas : '=' } take a look at this SO question for more info http://stackoverflow.com/questions/14050195/what-is-the-difference-between-and-in-directive-scope – masimplo Sep 28 '15 at 07:38
0

You also need to declare the dtaas variable as a 2-way-binding - not as simple string.

scope : {
        dtaas : '='
    },
Michael
  • 3,085
  • 1
  • 17
  • 15