Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

342
Vistas
How to use UpgradeComponent to a AngularJS directive that uses $attrs in Angular

Currently I have this .directive in 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
}

and I'm trying to use UpgradeComponent to be able to use this in 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>

But it fails... and the reason is explained here (basically it doesn't support $attrs).

So, the question is: how could I use that legacy directive without rewriting this right now?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda