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

261
Vistas
AngularJS calling an ng-controller embedded inside another controller

Here is a snippet of the cshtml:

<div>
    <button type="button" ng-click="recalcButton()">Recalc Button</button>
</div>
<div ng-controller="appealPartialController">
    <div ng-include="'/Partials/appealsPartial.html'"></div>
</div>

When recalcButton is clicked, I want to reload the data in appealPartialController. Any documentation or JS code examples would be greatly appreciated!

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

So, after much googling and a good idea fairy, I found a solution utilizing the built in $scope of angularJS and calling the load function from the parent.

$scope.$$childHead.$$nextSibling.loadAppealModel($scope.claimID);
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use a shared param. First of all you create a service like this:

import { Injectable, EventEmitter } from '@angular/core';
import { Subscription } from 'rxjs/internal/Subscription';

@Injectable({
  providedIn: 'root'
})
export class SharedParamsService {

  invokeFirstComponentFunction = new EventEmitter();
  subsVar: Subscription;

  constructor() { }

  onUpdateEnv(key, val) {
    var toEmit = [key, val]
    this.invokeFirstComponentFunction.emit(toEmit);
  }
}

Now you can emit a variable when clicking your button, so in your component, after importing SharedParamsService and declaring in your constructor private sharedParams: SharedParamsService:

recalcButton(){
    this.sharedParams.onUpdateEnv("btn", this.jobObj.name);
}

Finally, in the component you want to reload after importing SharedParamsService and declaring in your constructor private sharedParams: SharedParamsService:

 this.sharedParams.subsVar = this.sharedParams.
     invokeFirstComponentFunction.subscribe((emitted) => {
        if (emitted[0] == "btn") {
            this.ngOnInit();
        }
      });

of course you can avoid using the key, val way if you have only this button to check, but using this way you can subscribe to multiple buttons toggles or other variables.

about 4 years ago · Juan Pablo Isaza Denunciar
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