javascript - How to include custom directive to another custom directive's template(html) in angular js -
i hava directive already(appview) , has html load through templateurl. of now, need add 1 more custom directive template being used directive(appview).
please see code below , not working expected. on how can make work please?
view.html (template)
<div> <div class="dragdrop" id="dropzone" dropzone> //here custom directive <div class="fileupload btn btn-primary"> <span>upload assets</span> <input id="dzfile" type="file" class="upload" /> </div> </div> </div>
angular js
var appmodule = angular.module("newapp", []); appmodule.directive("appview", appview); function appview(){ var directive = { restrict: 'e', templateurl: 'app/view.html' }; return directive; } appmodule.directive("dropzone", function(){ //this added view.html attribute(see above html code **) var directive = { restrict: 'a', link: fulldragdrop }; return directive; }); function fulldragdrop(){ console.log("soemthing goes here"); }
how can make possible please?
this code works me. make sure templateurl: 'app/view.html' exists
<script> var appmodule = angular.module("newapp", []); appmodule.directive("appview", appview); function appview(){ var directive = { restrict: 'e', templateurl: 'view.html' }; return directive; } appmodule.directive("dropzone", function(){ //this added view.html attribute(see above html code **) var directive = { restrict: 'a', link: fulldragdrop }; return directive; }); function fulldragdrop(){ console.log("soemthing goes here"); } </script> <script type="text/ng-template" id="view.html"> <div class="dragdrop" id="dropzone" dropzone> //here custom directive <div class="fileupload btn btn-primary"> <span>upload assets</span> <input id="dzfile" type="file" class="upload" /> </div> </div> </script> <body> <app-view></app-view> </body>
Comments
Post a Comment