angularjs 动态加载事件的另一种实现
/** 初始化酒店列表 */ function inintHotel(params,url,$http,$scope){ $http.jsonp(url).success(function(res, status, header, config){ $scope.hotelList = res.data.list; }).error(function(res,xOptions, textStatus){ console.log(res); console.log(xOptions); console.log(textStatus); alert("服务器链接出现异常,请稍后再试!"); }); } var hotelApp = angular.module("hotelApp", []);//加载模块 hotelApp.controller("hotelCtrl",function($scope,$http){ var params = {}; params.classId = "967"; params.pageSize = "8"; var url = getUrlByJSONP("ActivityM.action?activityList=",params,"activityList"); inintHotel(params,url,$http,$scope); //点击地区筛选条件,动态生成onclick事件 $(".position-ul li").click(function(){ var b = false; var data = $(this).attr("data-param"); $(".serach-wh span").each(function(z,e){ var t = $(this).attr("data-param"); if(t == data){ b = true; } }); if(!b){ $(".position-ul li").each(function(j,k){ if(j!="0"){ $(this).removeAttr("id"); } }); $(this).attr("id","color-red"); var strHtml = "<span class='serach-frl' onclick='deleteAll();' data-param="+data+" title='点击关闭'>"+$(this).html()+"</span>"; $(".serach-postion").html(strHtml); } var params = {}; params.classId = "967"; params.pageSize = "8"; params.regionId = $(this).html(); var url = getUrlByJSONP("ActivityM.action?activityList=",params,"activityList"); inintHotel(params,url,$http,$scope); }); //清除所有条件 deleteAll = function(){ var serach = $(".serach-frl").remove(); var params = {}; params.classId = "967"; params.pageSize = "8"; var url = getUrlByJSONP("ActivityM.action?activityList=",params,"activityList"); inintHotel(params,url,$http,$scope); } });
时间,请带我像一条小溪流般,安静地流淌,汇入爱的海洋。