Skip to content

Instantly share code, notes, and snippets.

View ozgurrgul's full-sized avatar

Ozgur ozgurrgul

View GitHub Profile
{
"teaser_table": [
{
"id_profile": 1534,
"wager_type_id": 77837,
"name": "2 TEASER FB 6 PTS, BK 4 PTS",
"enabled": 1,
"teaser_team_count": 2,
"max_risk": "2000.0000",
"odds": -120,
const appRoutes: Routes = [
{
path: 'dashboard',
component: DashboardPageComponent,
canActivate: [NeedAuthGuard] // <---- connected Route with guard
},
{
path: 'login',
component: LoginPageComponent
},
import {CanActivate, Router} from '@angular/router';
import {Injectable} from '@angular/core';
import {CustomerService} from './customer.service';
import {ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router/src/router_state';
@Injectable()
export class NeedAuthGuard implements CanActivate {
constructor(private customerService: CustomerService, private router: Router) {
}
import {Injectable} from '@angular/core';
const TOKEN = 'TOKEN';
@Injectable({
providedIn: 'root'
})
export class CustomerService {
setToken(token: string): void {
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
import {LoginResultModel} from './model/LoginResultModel'
@Injectable({
providedIn: 'root'
})
export class ApiService {
import {Component} from '@angular/core';
import {ApiService} from '../api.service';
import {CustomerService} from '../customer.service';
import {Router} from '@angular/router';
@Component({
selector: 'app-login-page',
templateUrl: './login-page.component.html',
styleUrls: ['./login-page.component.css']
})
<div class="card mt-5" style="margin:auto;width: 600px;">
<div class="card-body">
<h5 class="card-title">Login</h5>
<div class="form-group">
<label for="email">Email</label>
<input type="text" class="form-control" id="email" placeholder="Email Address" [(ngModel)]="email">
</div>
<div class="form-group">
<label for="email">Password</label>
<input type="password" class="form-control" id="password" placeholder="Password" [(ngModel)]="password">
<template>
<div>
Hello World
</div>
</template>
<script>
export default {
name: 'welcome'
}
@Component({
selector: 'welcome',
template: '<div>Hello World</div>',
styleUrls: ['./welcome.component.css']
})
export class WelcomeComponent {
}
class Welcome extends React.Component {
render() {
return <div>Hello World!</div>;
}
}