javascript - 在 AngularJS 中重复完成的火灾事件

标签 javascript jquery angularjs

您好,我正在尝试在 AngularJS 中重复完成时触发一个事件,以下是代码:

以下是HTML代码

<li ng-repeat="y in names | limitTo: 6" repeat-done="ratingwithng()"> <a href="<?php echo $this->config->item('search_url');?>{{y.hosurl}}">
  <div class="hospital-card"> <img src="{{y.profile_image}}" width="" height="" />
    <h3 class="vlcc-name">{{y.clinic_name}}</h3>
    <div class="doc-rete">
      <div id="rateYo-hos" class="mc-doc-rating">3</div>
    </div>
    <p class="hospital-specialist">{{y.localty }} {{y.city }}</p>
    <p class="vlcc-experince">{{y.clinic_type }}</p>
    <p class="vlcc-address">{{y.hos_time }} </p>
  </div>
  </a>
</li>

以下是 AngularJS 代码:

var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {   
   $http.get("frontendapi/hospital_list")
   .then(function (response) {$scope.names = response.data.HospitalList;});  

    $http.get("frontendapi/NewsList")
   .then(function (response) {$scope.namesNews = response.data.Newslistfeature;});

   $http.get("frontendapi/NewsList")
   .then(function (response) {$scope.namesNewsRec = response.data.Newslist;});

   $http.get("frontendapi/NewsList")
   .then(function (response) {$scope.nameDoctor = response.data.records;});

   $http.get("frontendapi/people_list")
   .then(function (response) {$scope.nameDoctorShift = response.data.PeopleList;});

   $http.get("frontendapi/interviews_list")
   .then(function (response) {$scope.nameInterview = response.data.interviewslist;});

});
function ratingwithng()
{
    alert();
}

警报不起作用,请提出建议。

谢谢

最佳答案

您的函数必须是 $scope 对象之一,以便该 Controller 在 ng-repeat 上可见

var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {   
   $http.get("frontendapi/hospital_list")
   .then(function (response) {$scope.names = response.data.HospitalList;});  

    $http.get("frontendapi/NewsList")
   .then(function (response) {$scope.namesNews = response.data.Newslistfeature;});

   $http.get("frontendapi/NewsList")
   .then(function (response) {$scope.namesNewsRec = response.data.Newslist;});

   $http.get("frontendapi/NewsList")
   .then(function (response) {$scope.nameDoctor = response.data.records;});

   $http.get("frontendapi/people_list")
   .then(function (response) {$scope.nameDoctorShift = response.data.PeopleList;});

   $http.get("frontendapi/interviews_list")
   .then(function (response) {$scope.nameInterview = response.data.interviewslist;});

   $scope.ratingwithng = function ()
   {
      alert();
   }

});

关于javascript - 在 AngularJS 中重复完成的火灾事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40521439/

相关文章:

javascript - IE9的跨域谷歌文档请求

使用国际键盘输入印地语的 JavaScript 库

javascript - 有条件地以 Angular 应用一次性绑定(bind)

javascript - 如何从异步调用返回响应?

javascript - 不知道去哪里学习如何使用 javascript 创建我自己的 "like"按钮

javascript - jQuery $.on.apply 不工作

jQuery 选择器 : get the content of 1st element class containing specific word

javascript - 单击并拖动仅抓取对象的一部分

javascript - 使用javascript更改段落字体大小

jquery - 如何使用 Foundation 4 将 Orbit 导航箭头移出容器?