2

我最近开始使用 AngularJS 和 Lumx。我尝试添加可以在网站的“通知”选项卡下找到的通知。链接在这里

任何人,我得到的错误是

“错误:未定义 LxNotificationService”

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

下面是我的 app.js 文件

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

testing.controller('mainCtrl', function ($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 页面上的所有内容都运行良好,我认为我只是没有正确调用该服务。有人可以帮忙吗?

附言

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

<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>

提前谢谢你,尼尔

4

2 回答 2

6

您在定义模块时忘记指定lumx模块依赖项testing

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

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

angular.module('testing').controller('mainCtrl', [
  '$scope',
  'LxNotificationService',
function ($scope, LxNotificationService) {
  ... your code here ...
}
于 2015-02-19T13:59:48.433 回答
4

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

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

巴里

于 2015-02-19T14:04:07.040 回答