angularjs - Use ng-controller inside angular templates -
i passing ng-controller attribute in ng-template script tag as,
<script type="text/ng-template"  id="dirtemplate.html"  ng-controller="tmplctrl">. 
but variables inside controller scope not available inside template.
jsfiddle above code available at, http://jsfiddle.net/hb7lu/21925/
you can 1 of 2 ways not how you're doing it.
add ng-controller div consuming ng-include
  <body ng-app="myapp">   <script type="text/ng-template"  id="dirtemplate.html">      {{tmplvalue}}   </script>    <span ng-include="'dirtemplate.html'" ng-controller="tmplctrl"></span> </body> http://jsfiddle.net/hb7lu/21927/
or
add ng-controller in nested div inside template
<body ng-app="myapp">     <script type="text/ng-template"  id="dirtemplate.html">       <div ng-controller="tmplctrl">{{tmplvalue}}</div>     </script>      <span ng-include="'dirtemplate.html'"></span> </body> 
Comments
Post a Comment