How to call directive from template html in angularjs -


html

<script type="text/ng-template" id="profiletemplatehtml" >     <div class="container profilepopup-cont" align="center">         <div class="row">             <div class="col-sm-3 zero-margin-padding" align="center">                 <img id="displayimage" ng-src={{model.piclarge}} class="img-circle">             </div> ... </script>  

in html template file have call directive.my directive name 'help'.but if add call directive not working. how call directive inside html template in angularjs?

i'm not sure understand question. here jsfiddle demonstrate how use custom directive inside ng-template.

or try this..

angular.module('demo', [])    .directive('help', function() {      return {        template: '<div>help! {{info}}</div>',        scope: {          info: '@info'        }      };    })    .controller('mainctrl', ['$log',      function($log) {        this.hello = 'this mainctrl';        this.template = 'profile-template.html';          //construct        $log.debug('democtrl has been loaded');      }    ]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>    <body ng-app="demo">    <script type="text/ng-template" id="profile-template.html">      <div>this profile-template.html</div>      <div info="this directive info."></div>    </script>    <div ng-controller="mainctrl main">      <h2>just demo</h2>      <div>{{main.hello}}, include template {{main.template}}</div>      <hr>      <div ng-include src="main.template"></div>    </div>    </body>


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -