Skip to content

Instantly share code, notes, and snippets.

View philipszdavido's full-sized avatar

Chidume Nnamdi philipszdavido

View GitHub Profile
//src/app/app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { VotelinkComponent } from './components/votelink/votelink.component';
import { LinkComponent } from './components/link/link.component';
import { LinktextComponent } from './components/linktext/linktext.component';
import { PointsComponent } from './components/points/points.component';
import { AddlinkComponent } from './components/addlink/addlink.component';
//src/app/app.component.ts
import { Component } from '@angular/core';
import { Store } from '@ngrx/store'
import * as fromArticle from './redux/reducer'
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
//src/app/app.component.ts
import { Component } from '@angular/core';
import { Store } from '@ngrx/store'
import * as fromArticle from './redux/reducer'
import * as fromAction from './redux/actions/articles'
//src/app/app.component.ts
constructor(private store: Store<fromArticle.State>){
this.store.dispatch(new fromAction.AddArticleAction({id:1,link:'http:angular.io',title:'Angular',points:0}))
this.store.select(fromArticle.getArticles).subscribe(v => {
console.log(v)
})
}
@Input() points: number
@Output() upvote = new EventEmitter()
@Output() downvote = new EventEmitter()
upVoteArticle = () => {
this.upvote.emit()
}
downVoteArticle = () => {
this.downvote.emit()
}
<li><a (click)="upVoteArticle($event)" href="javascript:void(0);" class="link-black btn btn-sm btn-success"><i class="fa fa-thumbs-o-up margin-r-5"></i> Upvote</a></li>
<li><a (click)="downVoteArticle($event)" href="javascript:void(0);" class="link-black btn btn-danger btn-sm"><i class="fa fa-thumbs-o-down margin-r-5"></i> Downvote</a>
</li>
//src/app/components/linktext/linktext.component.html
<div class="user-block">
<a href="javascript:void(0);">{{titletext}}</a>
<div>Shared publicly - 7:30 PM today</div>
</div>
<!-- /.user-block -->
<p>
({{linktext}})
</p>