Created
October 18, 2016 08:56
-
-
Save jens1101/45ff582fcf8845ef42c374194657359b to your computer and use it in GitHub Desktop.
Angularjs basic transclusion with require
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('testApp', []) | |
| .component('parent', { | |
| template: '<h2>{{$ctrl.title}}</h2><div ng-transclude></div>', | |
| transclude: true, | |
| controller: function() { | |
| this.title = 'Foobar' | |
| } | |
| }) | |
| .component('child', { | |
| require: { | |
| parent: '^parent' | |
| }, | |
| controller: function() { | |
| this.$onInit = function() { | |
| console.log(this.parent); | |
| }; | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div ng-app="testApp"> | |
| <parent> | |
| <p>Bacon ipsum dolor amet doner burgdoggen fatback salami shoulder brisket, shankle ribeye tongue chicken. Biltong andouille tenderloin tail burgdoggen tri-tip pork belly drumstick alcatra ham hock kevin. Frankfurter andouille salami, beef ribs sausage | |
| kielbasa strip steak tenderloin biltong turkey meatball.</p> | |
| <child></child> | |
| </parent> | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment