Skip to content

Instantly share code, notes, and snippets.

View ctamyildirim's full-sized avatar

Cihan Tamyıldırım ctamyildirim

View GitHub Profile
@ctamyildirim
ctamyildirim / interfaceAddField.ts
Last active March 11, 2024 22:34
Typescript Interface ek alan ekleme.
interface Window {
title: string;
}
interface Window {
ts: TypeScriptAPI;
}
const src = 'const a = "Hello World"';
window.ts.transpileModule(src, {});
@ctamyildirim
ctamyildirim / extending.ts
Last active March 11, 2024 22:34
Typescript Extending
interface Animal {
name: string;
}
interface Bear extends Animal {
honey: boolean;
}
// Görüldüğü üzere bir Bear tipinde bir variable artık hem animal hem de
// bear tipindeki propertylere erişebilmekte.
@ctamyildirim
ctamyildirim / interface.ts
Last active March 11, 2024 22:34
Typescript Interface Kullanımı
interface Person {
name: string;
age: number;
}
let person: Person = {
name: "John Doe",
age: 30,
};
function getPerson(id: number): Person {
@ctamyildirim
ctamyildirim / interfacetDeterming.ts
Last active March 11, 2024 22:34
Typescript Interface
interface Person {
name: string;
age: number;
}
interface Address {
street: string;
city: string;
postalCode: number;
}
@ctamyildirim
ctamyildirim / Type.ts
Last active March 11, 2024 22:34
Typescript Type Kullanım
let person: Person = {
name: "John Doe",
age: 30,
};
// Aşağıdaki fonksiyon Person tipinde bir variable döndürmelidir.
function getPerson(id: number): Person {
// ...
}
@ctamyildirim
ctamyildirim / typeDeterming.ts
Last active March 11, 2024 22:34
Typescript Type
//Örnek1:
type Person = {
name: string;
age: number;
};
//Örnek2:
type Address = {
@ctamyildirim
ctamyildirim / basicTypes.ts
Last active March 11, 2024 22:33
Typescript Temel Türler
let num: number = 10;
// num değişkeni number türünde ve 10 değerine sahip
const str: string = "Merhaba Dünya!";
// str sabiti string türünde ve "Merhaba Dünya!" değerine sahip
@ctamyildirim
ctamyildirim / guard.ts
Created July 10, 2023 10:53
CanActivateFn
import { CanActivateFn } from '@angular/router';
const myGuard: CanActivateFn = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => {
// Burada kendi guard mantığınızı oluşturmalısınız
return true;
}
@ctamyildirim
ctamyildirim / app.routing.module.ts
Last active July 5, 2023 19:55
Router Guard Tanımlama
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
import { UserComponent } from './user/user.component';
import { AuthGuard } from './auth.guard';
import { ConfirmDeactivateGuard } from './confirm-deactivate.guard';
import { CanLoadGuard } from './can-load.guard';
const routes: Routes = [
@ctamyildirim
ctamyildirim / authGuard.ts
Created July 5, 2023 19:54
Router Guard canLoad
import { Injectable } from '@angular/core';
import { CanLoad, Route, UrlSegment } from '@angular/router';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class AuthGuard implements CanLoad {
canLoad(
route: Route,