我正在尝试使用Angular-Strap插件为用户创建消息,如下所示:
http://mgcrea.github.io/angular-strap/#/alerts#alerts
和以下的plunker
http://plnkr.co/edit/2xx07drMLCqmbmyVlv5n?p=preview
我确定我已正确添加了module.config,因为没关系,但在我的控制器中,当我将$ alert变量注入我的函数时,我收到了一个错误。这是错误:
TypeError: object is not a function
at AlertFactory (http://localhost:3000/components/angular-strap/dist/angular-strap.js:412:18)
at new <anonymous> (http://localhost:3000/controllers/form-controller.js:92:17)
当我在console.log($ alert)时 - 我得到:
function AlertFactory(config) {
var $alert = {};
// Common vars
var options = angular.extend({}, defaults, config);
$alert = $modal(options);
// Support scope as string options [/*title, content, */ type, dismissable]
$alert.$scope.dismissable = !!options.dismissable;
if(options.type) {
$alert.$scope.type = options.type;
}
// Support auto-close duration
var show = $alert.show;
if(options.duration) {
$alert.show = function() {
show();
$timeout(function() {
$alert.hide();
}, options.duration * 1000);
};
}
return $alert;
}
以下是我如何注射它:
angular.module('MyApp')
.controller('formController', ['$scope', 'Appointment', '$alert', function($scope, Appointment, $alert) {
console.log($alert);
}]);
FYI - components / angular-strap / dist / angular-strap.js:412:18 == $ alert = $ modal(options),这让我觉得$ module没有加载,但是应该加载Angular Strap的其余部分没有?
有人可以帮忙吗?