为什么角度承诺跟踪器对我不起作用
Why is angular-promise-tracker not working for me?
我已经安装了角度承诺跟踪器,我想我快要让它工作了。 我遇到的问题是"加载"文本没有显示。 数据被提取,并在将其输出到控制台时显示。
因此,ng-show="loadingTracker.active()"
似乎不起作用。 我看不出我做错了什么。
任何这方面的帮助将不胜感激 - 一如既往:)
这是我的代码:
.HTML
<button ng-controller="weatherCtrl"
ng-model="hotel"
class="btn btn-default"
ng-click="loadWeather(hotel, $index)">
{{buttonText}} more</button>
<div collapse="isCollapsed">
<div class="well well-lg more-detail">
{{hotel.Description}}
<br /><br />
<div>
<div class="my-super-awesome-loading-box"
ng-show="loadingTracker.active()">
Loading..
</div>
</div>
</div>
</div>
.JS
.controller('weatherCtrl', function ($scope, weather, $timeout, promiseTracker){
$scope.loadingTracker = promiseTracker();
$scope.buttonText= 'Load'
$scope.loadedHotelDetails=[];
$scope.loadWeather = function(hotel, index) {
// console.log('loadWeather')
weather.get({tracker: $scope.loadingTracker}, function (data){
console.log(data)
$scope.loadedHotelDetails.push(index)
})
})
angular.module('weather', [])
.factory('weather', function($http) {
var weather = {};
weather.get = function(params, callback) {
$http.get('/php/weather.php', {params: {tracker: params.tracker, page: params.page}}).success(function(data) {
callback(data);
});
};
return weather;
});
我从未使用过这个模块,但从 github 上的例子来看,我认为你应该在 weather
中这样称呼它:
weather.get = function(params, callback) {
$http.get('/php/weather.php', {tracker: params.tracker, page: params.page}).success(function(data) {
callback(data);
});
};
排序好了,这是我需要的代码:
.factory('weather', function($http) {
var weather = {};
weather.get = function(params) {
return $http.get('/php/weather.php', {tracker: params.tracker, page: params.page});
};
return weather;
});
相关文章:
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- 监视函数从服务返回不起作用,但作用域函数起作用
- 幻灯片滚动javascript不起作用
- 简单的javascript在Shopify中不起作用
- Recaptcha在IE7和IE8中不起作用
- Ember Data DS.Model's set函数不起作用
- JsFiddle上的鼠标事件不起作用
- 我的AngularJS表达式没有'不起作用
- 点击按钮输入不起作用
- 面向对象的Javascript代码在IE7中不起作用
- 分部隐藏在jquery中不起作用
- 在phonegap应用程序内部重定向不起作用
- 重定向到PDF时像素跟踪代码不起作用
- 谷歌分析事件跟踪 - 不起作用
- 为什么此事件跟踪器不起作用
- 跟踪像素应该通过引用页面加载外部网站 - 但它不起作用
- 为什么角度承诺跟踪器对我不起作用
- 谷歌分析跟踪事件不起作用
- 谷歌分析表单跟踪事件不起作用
- 为什么log4javascript.跟踪方法不起作用