Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <my-custom-element ng-transclude>
  2. <div>
  3. <h3>Scope: {[{$ctrl.test}]}</h3>
  4. </div>
  5. </my-custom-element>
  6.  
  7. function CustomDirective() {
  8. return {
  9. restrict: 'E',
  10. replace: true,
  11. controller: MyController,
  12. controllerAs: '$ctrl',
  13. transclude: true
  14. }
  15. }
  16.  
  17. export function register(ngModule) {
  18. ngModule.directive('myCustomElement', CustomDirective);
  19. }
  20.  
  21. const CustomComponent = {
  22. controller: MyController,
  23. transclude: true,
  24. replace: true,
  25. };
  26.  
  27. export function register(ngModule) {
  28. ngModule.component('myCustomElement', CustomComponent);
  29. }
  30.  
  31. export default class MyController {
  32. constructor() {
  33. this.test = 'this is just a teststring';
  34. }
  35. }
  36.  
  37. const CustomComponent = {
  38. controller: MyController,
  39. transclude: true,
  40. template: '<ng-transclude></ng-transclude>'
  41. };
  42.  
  43. export function register(ngModule) {
  44. ngModule.component('myCustomElement', CustomComponent);
  45. }
  46.  
  47. <my-custom-element>
  48. <div>
  49. <h3>Scope: {[{ $parent.$ctrl.test }]}</h3>
  50. </div>
  51. </my-custom-element>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement