Skip to content

Instantly share code, notes, and snippets.

View philipszdavido's full-sized avatar

Chidume Nnamdi philipszdavido

View GitHub Profile
<div>Shared publicly - {{ time | date:'medium' }}</div>
//src/app/component/linktext/linktext.component.html
<div class="user-block">
<h3>{{titletext}}</h3>
<div>Shared publicly - {{ time | date:'medium' }}</div>
</div>
<!-- /.user-block -->
<p>
({{linktext}})
</p>
//src/app/component/linktext/linktext.component.ts
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-linktext',
templateUrl: './linktext.component.html',
styleUrls: ['./linktext.component.css']
})
export class LinktextComponent implements OnInit {
//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'
import { Article } from './redux/models/article';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
<button [disabled]='!addLinkForm.valid' type="submit" class="btn btn-primary">Submit Article</button>
this.addLinkForm = this.fb.group({
title: ['',[Validators.required,Validators.minLength(4)]],
article: ['',[Validators.required,Validators.minLength(4)]]
})
import { FormBuilder,FormGroup,Validators, FormControl } from '@angular/forms';
//this was deprecated for brevity
<form [formGroup]='addLinkForm' (ngSubmit)="addLink()">
<input type="text" class="form-control input-lg" id="title" placeholder="Write Your Title" formControlName='title'>
<input type="text" class="form-control input-lg" id="article" placeholder="Write Your Article Link" formControlName='article'>
</form>
constructor(private fb: FormBuilder) {
constructor(private fb: FormBuilder) {
this.addLinkForm = this.fb.group({
title: ['',[Validators.required,Validators.minLength(4)]],
article: ['',[Validators.required,Validators.minLength(4)]]
})
}