6 Kasım 2019 Çarşamba

why we use moduleId:module.id in angular2


relative assets for components, like templateUrl and styleUrls in the @Component decorator.
moduleId is used to resolve relative paths for your stylesheets and templates as it says in the documentation.
Without Module ID
@Component({
  selector: 'my-component',
  templateUrl: 'app/components/my.component.html',
  styleUrls:  ['app/components/my.component.css'] 
})
With Module ID
@Component({
  moduleId: module.id,
  selector: 'my-component',
  templateUrl: 'my.component.html', 
  styleUrls:  ['my.component.css'] 
})

21 Mart 2019 Perşembe

Json Data verilen navigasyon içeriğini getirme

getDataByNav(dataNav: string, response: any) {
const navs = dataNav.split('.');
let lastObj = Object.assign([], response);
if (navs && navs.length > 0) {
for (let i = 0; i < navs.length; i++) {
lastObj = lastObj[navs[i].toString()]
}
}
return lastObj;
}

9 Ocak 2019 Çarşamba

ng build

ng build --prod --env=env_name --app=appname --base-href /app_name_path/ 

25 Aralık 2018 Salı

Copy Paste Trim and Only Numeric

import { OnInit, Directive, HostListener, EventEmitter, Output } from "@angular/core";

@Directive({
selector: "[copyPasteTrimAndOnlyNumeric]",
providers: []
})
export class CopyPasteTrimAndOnlyNumericDirective {

@Output() ngModelChange: EventEmitter<any> = new EventEmitter();
value: any;

constructor() { }

ngOnInit(): void { }

@HostListener('paste', ['$event']) onPaste(e: ClipboardEvent) {
debugger
e.preventDefault();
let pastedText = e.clipboardData.getData('text');
if (pastedText) {
pastedText = pastedText.replace(/[^0-9]+/g, '')
if (pastedText && pastedText.length > 11)
pastedText = pastedText.substring(0, 11);
this.ngModelChange.emit(pastedText);
}
}
}

3 Aralık 2018 Pazartesi

Enum Display Name'ini çekme

using System;
using System.ComponentModel.DataAnnotations;
using System.Reflection;

public static class EnumExtensions
{
    public static string GetDisplayName(this Enum enu)
    {
        var attr = GetDisplayAttribute(enu);
        return attr != null ? attr.Name : enu.ToString();
    }

    public static string GetDescription(this Enum enu)
    {
        var attr = GetDisplayAttribute(enu);
        return attr != null ? attr.Description : enu.ToString();
    }

    private static DisplayAttribute GetDisplayAttribute(object value)
    {
        Type type = value.GetType();
        if (!type.IsEnum)
        {
            throw new ArgumentException(string.Format("Type {0} is not an enum", type));
        }

        // Get the enum field.
        var field = type.GetField(value.ToString());
        return field == null ? null : field.GetCustomAttribute<DisplayAttribute>();
    }
}

21 Kasım 2018 Çarşamba

Httpden dönen json datanın hepsini localStorage'e atma

var dataProperties = Object.getOwnPropertyNames(responseStart.data);
for(let i=0;i<datapProperties.length;i++){
localStorage.setItem(prefix+dataProperties[i],responseStart[dataProperties[i]])
}

12 Kasım 2018 Pazartesi

Angular Component değer alma, değer yollama/yayınlama

import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';

@Component({
selector: 'ip-address',
templateUrl: './ip-address.component.html',
})
export class IpAddressComponent implements OnInit {

ipAddressParts: any[] = ["0", "0", "0", "0"];

tempValue;

@Input("value")
set IpAddressComponent(value: string) {
if (typeof value !== 'string' || value.indexOf('.') === -1) {
return;
}
else {
var parts = value.split(".");
for (let index in parts) {
this.ipAddressParts[index] = +parts[index];
}
}
}

get IpAddressComponent() {
return this.ipAddressParts.join(".");
}

@Output("value")
public ipAddressEmitter = new EventEmitter<string>();

constructor() { }

ngOnInit() {
}

}

.net 6 mapget kullanımı

 app.UseEndpoints(endpoints => {     endpoints.MapGet("/", async context =>     {         var response = JsonConvert.Seriali...