Angular Toast在我的服务中不起作用
Angular-Toaster not working in my service?
我已经从这个网站了解了tover.js,并试图在我的web应用程序中实现它。我已经按照这个例子做了,但不起作用。
这是我实现的服务:
function () {
angular
.module('FoursquareApp')
.factory('DataService', DataService);
DataService.$inject = ['$http','toaster'];
function DataService($http, toaster) {
.id,
venueName: venue.name,var serviceBase = '/api/places/';
var placesDataFactory = {};
var userInContext = null;
var _getUserInCtx = function () {
return userInContext;
};
var _setUserInCtx = function (userInCtx) {
userInContext = userInCtx;
};
var _savePlace = function (venue) {
//process venue to take needed properties
var minVenue = {
userName: userInContext,
venueID: venue
address: venue.location.address,
category: venue.categories[0].shortName,
rating: venue.rating
};
return $http.post(serviceBase, minVenue).then(
function (results) {
toaster.pop('success', "Bookmarked Successfully", "Place saved to your bookmark!");
},
function (results) {
if (results.status == 304) {
toaster.pop('note', "Faield to Bookmark", "Something went wrong while saving :-(");
}
else {
toaster.pop('error', "Failed to Bookmark", "Something went wrong while saving :-(");
}
return results;
});
};
我已经调用了index.html中的库脚本和css文件。
你知道我可能做错了什么吗?
您确定使用toaster.js
库吗?流行的是toastr.js
尝试将您的代码修改为
DataService.$inject = ['$http','toastr'];
function DataService($http, toastr) {
...
还要确保在index.html中链接这个js文件,并在主应用程序模块定义中将这个包作为第二个(依赖)参数
相关文章:
- 监视函数从服务返回不起作用,但作用域函数起作用
- 角度控制器服务承诺不起作用
- 为什么从 Angular 服务中的对象中删除此元素不起作用
- 对SOAP服务的Preflight OPTIONS请求不起作用
- http的自定义服务不起作用
- AngularJs 简单的自定义服务不起作用
- 静态内容服务在快递中不起作用
- 为什么Angular的$http.get服务不起作用
- 移动 Web 服务不起作用
- 为什么当服务注入第二个控制器时,AngularJS 1.4.8 应用程序不起作用
- Firefox Addon Builder首选项-服务对我不起作用--为什么
- 从本地文件获取JSON的角度服务不起作用
- 角度模态>Ctrl+gt;服务>Ctrl继承不起作用
- Angular ui路由器在服务中保存到状态名称不起作用
- Angular Toast在我的服务中不起作用
- Azure移动服务javascript SDK在Firefox中不起作用
- 方法POST在向REST服务发送请求时不起作用
- Javascript web服务请求不起作用
- 在AngularJS服务中显示模块模式的Javascript不起作用
- 谷歌地图API的方向服务;不起作用