0

The template that loads content("html/script template") for each cell:

<td class="tableColumnsDocs" ng-repeat="attobj in columns track by $index" >
  <div ng-init="values = dbo.get4(attobj.key); key = attobj.key; template = attobj.template || getAttributeTemplate(dbo.clazz + attobj.key);">
      <div plain-template="template">
      </div>
  </div>
</td>

I need the directive to access the value "template" from its directive "plain-template"

Directive:

app.directive('plainTemplate', function($parse) {
  return {
    templateUrl: 'testTemplate',
    function (scope, element, attrs) {

        console.log($parse(attrs.plainTemplate));
    }
  };
});
Al Ex Tsm
  • 2,042
  • 2
  • 29
  • 47

1 Answers1

1

You can use something like

app.directive('plainTemplate', function($parse) {
  return {
    templateUrl: 'testTemplate',
    scope: {
      plainTemplate:"=" 
    },
    link: function (scope, element, attrs) {
        console.log(scope.plainTemplate));
    }
  };
});

and when you call it in html your variable should be like

<plain-template test-template="anything"> </plain-template>

this is isolated scope. You can see more at https://docs.angularjs.org/guide/directive

krish
  • 537
  • 2
  • 14
  • Cool thanks, but what if the isolated scope variable is holding the templateUrl, can I return the templateUrl after the link function? – Al Ex Tsm Nov 25 '15 at 12:09
  • 1
    Can do something like this : http://stackoverflow.com/questions/21835471/angular-js-directive-dynamic-templateurl – krish Nov 25 '15 at 12:12