Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
Pasar método hijo padre angular js

tengo esta funcion:

 $scope.link = function (){ return [{ value: 'https://www.google.it', text: 'go to details' } ] }

quiero pasar esta función en el controlador principal al niño, traté de hacer esto:

 .directive('card', function(){ var TPL = `<div class="card" style="width: 18rem"> <div class="card-body"> <p>{{c.paragrafo}}</p> <h4 class="card-title">{{c.title}}</h4> <h6 class="card-subtitle mb-2 text-muted">{{c.paragrafo2}}</h6> <p class="card-text"></p> <a class="card-link">{{c.link()}}</a> </div> </div>` var directive = { restrict: 'E', template: TPL, scope: { paragrafo: '@', title: '@', paragrafo2: '@', link: '&' }, controller: ctrlFn, controllerAs: 'c', bindToController: true }; return directive; function ctrlFn(){ } })

y en index.html:

 <body ng-app="app" ng-cloak> <div ng-controller="MainCtrl"> <div class="container"> <div class="row"> <div class="col" ng-repeat="demo in demos"> <card title="{{demo.title}}" paragrafo="{{demo.paragrafo}}" paragrafo2="{{demo.paragrafo2}}" link="link()" ></card> </div> </div> </div> </div> </body>

Pero el cuerpo de la función vuelve a mí, ¿cómo puedo solucionar esto? Quiero ver el texto del enlace "ir a detalles" y cuando hago clic en él me lleva a la página de google

over 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Virtual assistant