我最近开始与AngularJS和Lumx合作。我尝试添加通知,可以在站点的int 'notification‘选项卡下找到。链接在这里。
不管怎么说,我得到的错误是
“错误: LxNotificationService未定义”
因此,我将它添加到控制器中的服务列表中。
下面是我的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页面上的所有内容都很正常,我想我只是没有正确地调用服务。有人能帮忙吗?
附注:
下面是我所有脚本文件的列表。
<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>提前谢谢你,尼尔
发布于 2015-02-19 14:04:07
不是100%,因为我是LumX新手,但是看起来您缺少了LumX模块的一个依赖项
var app = angular.module('myApp', ['lumx']);巴里
发布于 2015-02-19 13:59:48
您在定义lumx模块时忘记指定testing模块依赖项:
angular.module('testing', ['lumx']);
此外,您还忘记在控制器中注入LxNotificationService:
angular.module('testing').controller('mainCtrl', [
'$scope',
'LxNotificationService',
function ($scope, LxNotificationService) {
... your code here ...
}https://stackoverflow.com/questions/28608140
复制相似问题