LxNotificationService 服务在 AngularJS 应用程序中不工作

LxNotificationService service not working in AngularJS app

我最近开始使用 AngularJS 和 Lumx。我已经尝试添加可以在网站的 'notification' 选项卡下找到的通知。 Link is here.

任何人,我得到的错误是

"Error: LxNotificationService is not defined"

所以我将它添加到控制器中的服务列表中。

下面是我的app.js文件

var testing = angular.module('testing', []);

testing.controller('mainCtrl', 函数 ($scope){

$scope.notify = function(type)
{
    if (type === 'simple')
    {
        LxNotificationService.notify('Lorem Ipsum');
    }
    else if (type === 'sticky')
    {
        LxNotificationService.notify('Lorem Ipsum', undefined, true);
    }
    else if (type === 'icon')
    {
        LxNotificationService.notify('Lorem Ipsum', 'android');
    }
    else if (type === 'color')
    {
        LxNotificationService.notify('Lorem Ipsum', undefined, false, 'grey');
    }
    else if (type === 'info')
    {
        LxNotificationService.info('Lorem Ipsum');
    }
    else if (type === 'success')
    {
        LxNotificationService.success('Lorem Ipsum');
    }
    else if (type === 'warning')
    {
        LxNotificationService.warning('Lorem Ipsum');
    }
    else if (type === 'error')
    {
        LxNotificationService.error('Lorem Ipsum');
    }
};

});

html 页面上的所有内容都工作正常,我想我只是没有正确调用服务。有人可以帮忙吗?

P.S.

下面是我所有脚本文件的列表。

<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/velocity/velocity.js"></script>
<script src="bower_components/moment/min/moment-with-locales.js"></script>
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/lumx/dist/lumx.min.js"></script>
<script src="app.js"></script>

提前谢谢你,尼尔

您在定义 testing 模块时忘记指定 lumx 模块依赖关系:

angular.module('testing', ['lumx']);

而且你忘了在你的控制器中注入 LxNotificationService :

angular.module('testing').controller('mainCtrl', [
  '$scope',
  'LxNotificationService',
function ($scope, LxNotificationService) {
  ... your code here ...
}

不是 100%,因为我是 LumX 的新手,但看起来您缺少 LumX 模块的依赖项

var app = angular.module('myApp', ['lumx']);

巴里