Blame view

src/app/layout/blocks/block-content.component.ts 794 Bytes
5e222a22   Victor Costa   Migrate block com...
1
2
3
import { Input, Inject, Component } from 'ng-forward';

@Component({
3963f52f   Victor Costa   Rename BlockCompo...
4
    selector: 'noosfero-block-content',
5e222a22   Victor Costa   Migrate block com...
5
6
7
    template: '<div></div>'
})
@Inject("$element", "$scope", "$injector", "$compile")
3963f52f   Victor Costa   Rename BlockCompo...
8
export class BlockContentComponent {
5e222a22   Victor Costa   Migrate block com...
9
10
11
12
13

    @Input() block: any;
    @Input() owner: any;

    ngOnInit() {
172c82f5   Victor Costa   Add discussion bl...
14
        let blockName = (this.block && this.block.type) ? this.block.type.replace(/::/, '').replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase() : "default-block";
d003d3ce   Victor Costa   Migrate link list...
15
        this.$element.replaceWith(this.$compile('<noosfero-' + blockName + ' [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-' + blockName + '>')(this.$scope));
5e222a22   Victor Costa   Migrate block com...
16
17
18
19
20
    }

    constructor(private $element: any, private $scope: ng.IScope, private $injector: ng.auto.IInjectorService, private $compile: ng.ICompileService) {
    }
}