我在 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"
));
角应用:
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