Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 有棱角的烤面包机不能为我服务吗?_Javascript_Angularjs - Fatal编程技术网

Javascript 有棱角的烤面包机不能为我服务吗?

Javascript 有棱角的烤面包机不能为我服务吗?,javascript,angularjs,Javascript,Angularjs,我从中了解了toaster.js,并尝试在我的web应用程序中实现它。我已经按照例子做了,但不起作用 以下是我实施的服务: function () { angular .module('FoursquareApp') .factory('DataService', DataService); DataService.$inject = ['$http','toaster']; function DataService($http, to

我从中了解了toaster.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文件,并在主应用程序模块定义中将此包作为第二个(依赖项)参数引用

您可以将url发布到下面的示例中,以便其他人能够理解您所引用的内容。@DrCox我已添加了url。感谢您指出这一点,您有任何错误吗?
未知提供程序:toasterProvider无法工作,但仍然存在相同的错误。表示要提供unkownSo确保在
index.html
中链接此js文件,并在主应用程序模块定义中将此程序包作为第二个(依赖项)参数引用。感谢它起作用。忘记添加参数。谢谢!:)