Simon
Simon

Reputation: 1476

directive not showing scope in template

something simple im sure.. ive set up a very simple directive that accepts an isolated scope item

the template simply prints out the name.

  .directive('createDirective', function () {
      return {
          restrict: 'E',
          template: '<div>{{name}} - 123</div>',
          scope: { name:'&myName'}
      }
  });

the HTML:-

 <create-directive my-name="bob" ></create-directive>

however, its failing to print out 'bob' im failing to see why not?

Upvotes: 1

Views: 410

Answers (1)

dfsq
dfsq

Reputation: 193261

Scope configuration is incorrect. It should be:

scope: {
    name: '@myName'
}

Special character & is used to setup a function reference to the outer scope function.

Upvotes: 1

Related Questions