An open API service indexing awesome lists of open source software.

https://github.com/mcasimir/angular-multiple-transclusion

Simple unobtrusive angular multiple transclusion support with ng-transclude
https://github.com/mcasimir/angular-multiple-transclusion

Last synced: about 2 months ago
JSON representation

Simple unobtrusive angular multiple transclusion support with ng-transclude

Awesome Lists containing this project

README

        

# Angular Multiple Transclusion

## A concise way to use multiple `ng-transclude` directives within the same AngularJs template.

Angular Multiple Transclusion extends `ng-transclude` to add support for multiple transclusion.

``` html







```

## Demo

http://codepen.io/mcasimir/pen/XbapYd

## Install

```
bower i --save angular-multiple-transclusion
```

## Usage

**Example task:** Create a `myPanel` directive transcluding a fragment to the header and a fragment to the body.

Use `transclude-from` attribute along with `ng-transclude` directive to define insertion points for transclusion:

``` js
angular.module('myApp', ['angular-multiple-transclusion'])

.directive('myPanel', function(){
return {
restrict: 'E',
transclude: true,
template:
'

' +
'
' +
'
' +
'
' +
'
' +
'
'
};
});
```

Use `transclude-to` to wire each element to the respective `ng-transclude` block:

``` html


Hi there!

Lorem ipsum dolor sit amet...

```

## Works with isolated scopes

``` js
.directive('myDialog', function(){
return {
restrict: 'E',
scope: {
title: '@'
},
transclude: true,
template:
'

' +
'
{{title}}
' +
'
' +
'
' +
'
' +
'
' +
'
'
};
});
```

``` html


Are you sure?


Save {{title}}

```

## Why multiple transclusion rocks?

See how people at [OpenTable](http://www.opentable.com) uses multiple transclusion with angular to create reusable components:

- https://www.airpair.com/angularjs/posts/creating-container-components-part-2-angular-1-directives