单击提交按钮时,我在控制台中遇到了这个消息,如果有人可以帮助我如何将时刻从node_modules导入到angula2项目!!
我的应用程序组件.html
<form class="ui large form segment">
<h3 class="ui header">Add a Link</h3>
<div class="field">
<label for="title">Title:</label>
<input name="title" #newtitle>
</div>
<div class="field">
<label for="link">Link:</label>
<input name="link" #newlink>
</div>
<div>
<button (click) ="addArticle(newtitle, newlink)" class="ui positive button">Submit link</button>
</div>
</form>
My app.module.ts
export class AppModule {
addArticle(title: HTMLInputElement, link:HTMLInputElement): boolean{
console.log('title: ${title.value} and link: ${link.value}');
return false;
}
}
你已经在 app.module.ts 中编写了 addArticle 方法,你应该把它放在 app.component.ts 中
export class AppModule {
addArticle(title: HTMLInputElement, link:HTMLInputElement): boolean{
console.log('title: ${title.value} and link: ${link.value}');
return false;
}
}
将 addArticle 方法移动到 app.component.ts,就像你在 app.component 中使用它一样.html
export class AppComponent {
title = 'Okay, proceed .!';
names = [];
// myDate = Date;
constructor(){
this.names = ['Tuan','Mark','Kevin'];
// this.myDate = new Date();
}
addArticle(title: HTMLInputElement, link:HTMLInputElement): boolean{
console.log('title: ${title.value} and link: ${link.value}');
return false;
}
}
目前使用以下导入
import {MomentModule} from 'angular2-moment/module';
npm install angular2-moment
后. http://ngmodules.org/modules/angular2-moment