> A simple AngularjS component for compiling components dynamically.
npm install angular-compile-componentThis component allows you to render components dynamically into your views, based on their name. To pass attributes you simply define an object with the properties required by the target-component's bindings. Check out the example below for getting started.
---
shell
npm i ng-compile-component
`---
$3
`html
`$3
`html
`$3
`javascript
angular.module('app', ['rckd.utils']);
`
Now you are ready to rumble!---
Usage
Attributes:
>
component
> Contains the name of the target-component (i.e. "myFancyComponent" or "my-fancy-component")>
bindings
> An object which represents the bindings of the target-component.$3
Inside of your component's controller:
`javascript
this.component = 'message-box';
this.bindings = {
title: 'Hey',
message: 'You wanna compile something?',
buttons:{
no: true
yes: true
}
};
`Inside of your html:
`html
component='$ctrl.component'
bindings='$ctrl.bindings'
>This results in:
`html
title='{{ $ctrl["title"] }}'
message='{{ $ctrl["message"] }}'
buttons='$ctrl["buttons"]'
>
`
---Define values inline:
`html
component='"message-box"'
bindings="{
title: 'Hey',
message: 'You wanna compile something?',
buttons:{
yes: true,
no: tru
}
}"
>
``