Actualmente tengo esta .directive
en AngularJS:
aegroApp.directive('poorLegacy', function () { return { restrict: 'E', scope: { hasSomething: '=?', anotherBinding: '@', }, controller, templateUrl: function (_, attrs) { return attrs.hasSomething ? 'file.html' : 'file2.html'; }, } }); function controller($attrs, /* others */) { // perform some checks with $attrs // rest of the code }
y estoy tratando de usar UpgradeComponent para poder usar esto en Angular:
@Directive({ selector: 'my-bridge' }) export class MyBridgeDirective extends UpgradeComponent { @Input() hasSomething?: boolean; @Input() anotherBinding?: string; constructor(elementRef: ElementRef, injector: Injector) { super('poorLegacy', elementRef, injector); } }
<my-bridge [hasSomething]="false"></my-bridge>
Pero falla... y el motivo se explica aquí (básicamente no es compatible $attrs
).
Entonces, la pregunta es: ¿cómo podría usar esa directiva heredada sin volver a escribir esto ahora?