我正在尝试将通知模块集成到我的应用程序中,作为此处发布的参考-https://github.com/bonnici/light-bootstrap-dashboard-angularcli
Build:Property'notify'在'JQueryStatic'类型上不存在。
这是我的notification.service.ts文件看起来像
import { Injectable } from '@angular/core';
export enum NotificationType {
Info = 1,
Success,
Warning,
Danger
}
export class NotificationOptions {
public message: string;
public icon: string = null;
public timer = 4000;
public type: NotificationType = NotificationType.Info;
public from = 'top';
public align = 'right';
public constructor(
fields: {
message: string,
icon?: string,
timer?: number,
type?: NotificationType,
from?: string,
align?: string
}) {
this.message = fields.message;
this.icon = fields.icon || this.icon;
this.timer = fields.timer || this.timer;
this.type = fields.type || this.type;
this.from = fields.from || this.from;
this.align = fields.align || this.align;
}
}
@Injectable()
export class NotificationService {
constructor() { }
public notify(options: NotificationOptions): void {
let typeString;
switch (options.type) {
case NotificationType.Success:
typeString = 'success';
break;
case NotificationType.Warning:
typeString = 'warning';
break;
case NotificationType.Danger:
typeString = 'danger';
break;
default:
typeString = 'info';
break;
}
$.notify(
{
icon: options.icon,
message: options.message
},
{
type: typeString,
timer: options.timer,
placement: {
from: options.from,
align: options.align
}
});
}
}
在我的.component.ts文件中,我像下面这样打电话
import { NotificationService, NotificationOptions } from '../../shared/services/notification.service';
constructor(private notificationService: NotificationService) { }
ngOnInit(): void {
this.notificationService.notify(new NotificationOptions({
message: 'Welcome!',
icon: 'pe-7s-gift'
}));
}
但是,在编译期间,我在VS2015中的$ .notify函数出现错误,如下所示
属性“ notify”在类型“ JqueryStatic”上不存在
符号通知无法正确解析,可能位于不可访问的模块中
当我的用户($任何)。通知异常已从VS编译。但是,页面抛出错误$ .notify不是一个函数。
这里有什么帮助吗?
最佳答案
但是,页面抛出错误$ .notify不是一个函数。
确保在引导javascript之后加载引导javascript。
更多
Bootstrap文档:http://getbootstrap.com/javascript/
关于javascript - $ .notify不是使用 typescript 的函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43729061/