我在asp.net mvc应用程序中有一个Angular应用程序。我无法让ngToast工作。没有显示Toast消息,我也没有看到任何错误。提前感谢您的帮助。
BundleConfig.cs
//angular scripts
bundles.Add(new ScriptBundle("~/bundles/angular").Include(
"~/Scripts/angular.js",
"~/Scripts/angular-route.js",
"~/Scripts/angular-animate.js",
"~/Scripts/angular-sanitize.js",
"~/Scripts/ngmodules/angular-modal-service.js",
"~/Scripts/modules/ngToast.js",
"~/Scripts/i18n/angular-locale_el-GR.js",
"~/Scripts/ngmodules/ng-qtip2.js",
"~/Scripts/ngmodules/ng-lodash.js",
"~/Scripts/angular-summernote.min.js"
));
bundles.Add(new StyleBundle("~/plugins/ngtoast").Include(
"~/Content/plugins/ngToast/ngToast.css"
));
Angular app:
var app = angular.module('messagingApp', [
// Angular modules
'ngAnimate',
'ngRoute'
// 3rd Party Modules
, 'ngToast'
, "angularModalService"
, "summernote"
]);
在ng控制器中(我使用ngToast.create()包含一个函数):
(function () {
"use strict";
angular
.module('messagingApp')
.controller('messagecontroller', mController);
mController.$inject = ['$scope', '$location', "$window", "$filter", "$routeParams", "$route", "$rootScope", "ngToast", "mService"];
function mController($scope, $location, $window, $filter, $routeParams, $route, $rootScope, ngToast, mService) {
//some functions
$scope.refreshMailbox = function () {
mService.getMessagesCount().then(function (data) {
$scope.inboxCount = data.CountInbox;
$scope.sentCount = data.CountSent;
if (data.CountNew > $scope.newCount) {
ngToast.create('You have new messages');
}
$scope.newCount = data.CountNew;
$scope.importantCount = data.CountImportant;
});
mService.getInbox($scope.currentPage).then(function (data) {
$scope.messages = data.Messages;
$scope.currentPage = data.CurrentPage;
});
}
};
})();
在我的cshtml文件末尾
@Styles.Render("~/plugins/ngtoast")
@Scripts.Render("~/bundles/angular")
//other scripts