首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >角2:无法读取未定义的属性“那么”以进行推送通知

角2:无法读取未定义的属性“那么”以进行推送通知
EN

Stack Overflow用户
提问于 2017-06-27 09:54:48
回答 1查看 1.1K关注 0票数 1

我试着在按钮点击上显示一个按钮通知。

我被一个角承诺错误困住了,它说:

无法读取未定义的属性“则”

全错误堆栈跟踪:

未定义错误:./AppComponent类AppComponent中的错误-内联模板:17:2原因是:无法读取未定义的属性‘那么’ DebugAppView.View_AppComponent0.handleEvent_16 (/AppModule/AppComponent/component.ngfactory.js:129) at PushNotificationComponent.show (notification.component.js:42) at DebugAppView.eventHandler (view.js:664) at HTMLButtonElement.COMPONENT_REGEX (dom_renderer.js:489) at ZoneDelegate.invokeTask (zone.js:367) at ng_zone (ng_zone )( .js:264)在ZoneDelegate.invokeTask (zone.js:366) at Zone.runTask (zone.js:166) at HTMLButtonElement.cancelFn.invoke (zone.js:420)

我正在使用github链接:

https://github.com/alexcastillo/ng2-notifications/blob/master/src/app/app.component.html

我的app.module.ts如下:

代码语言:javascript
复制
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';

import { PushNotificationComponent } from 'ng2-notifications/src/app/components/notification.component';

@NgModule({
   declarations: [
    AppComponent,
    PushNotificationComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule

  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.component.ts

代码语言:javascript
复制
import { Component } from '@angular/core';
import {
  Directive,
  EventEmitter,
  OnInit,
  OnChanges,
  OnDestroy,
  Input,
  Output
} from '@angular/core';

import '../style/app.scss';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
 })
@Directive({
 selector: 'push-notification'
})
export class AppComponent {
  title: string = 'ng2-notifications';
  description: string = 'Angular 2 Component for Native Push Notifications';

  constructor() {
  }
}

app.component.html

代码语言:javascript
复制
<header>
    <h1 class="title">{{ title }}</h1>
</header>
<main>

    <h2>{{ description }}</h2>

    <img src="img/demo.gif">

    <push-notification #notification title="ng2-notifications" body="Native Push Notifications in Angular 2" icon="<some_ulr>" closeDelay="2000" (load)="notification.show()"> //Problem Here!!
    </push-notification>

    <button (click)="notification.show()">Show Notification</button>

</main>

如果我删除行:(load)="notification.show()似乎不错,但它没有任何用途,没有通知后,按一下按钮!

EN

回答 1

Stack Overflow用户

发布于 2017-06-27 09:57:30

错误出现在这里:

app.component.ts中删除此代码块

代码语言:javascript
复制
@Directive({
 selector: 'push-notification'
})

注意:

https://github.com/alexcastillo/ng2-notifications是用转角的beta版本编码的,所以可以找到更新的版本或不同的插件。 给定的Doc也是关于转角的beta版本的

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44777297

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档