angularjs - Concat Template With Custom Directive Template -
i'm not sure if possible accomplish want. i'll seek explain example:
a custom directive:
appdirectives.directive("mytestdirective", function() { homecoming { restrict: "e", templateurl: "<div> template here... {{ testobject }} <div>", scope: { 'testobject' = '@testobject' } }; }]); use directive in tempalte:
<my-test-directive testobject="and more here..."> <div> want in template! </di> </my-test-directive> and want accomplish template:
<div> template here... , more here... <div> <div> want in template! </di>
you can transclusion. add together param directive, , utilize ng-transclude on element want have contents inserted.
you might have remove original since transclusion needs element operate on, basic idea.
class="snippet-code-js lang-js prettyprint-override">angular.module('test', []) .directive('mytestdirective', function() { homecoming { restrict: "e", template: "<div> template here... {{testobject}} <div><div ng-transclude></div>", scope: { testobject: '@' }, transclude: true }; }); class="snippet-code-html lang-html prettyprint-override"><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="test"> <my-test-directive test-object="and more here..."> <div> want in template! </div> </my-test-directive> </div>
angularjs angularjs-directive
No comments:
Post a Comment