Skip to content

Instantly share code, notes, and snippets.

<!-- work -->
<div class="wave" [style.height.px]="step.DoneItemCount/step.TotalItemCount*150"></div>
<!-- not work -->
<div class="wave" [ngStyle]="{height:step.DoneItemCount/step.TotalItemCount*150}"></div>
@jiaming0708
jiaming0708 / app.component.ts
Last active February 23, 2017 16:10
ViewChild&ContentChild
import { Component, ViewChild, AfterContentInit } from '@angular/core';
import { TabComponent } from './tab.component';
@Component({
selector: 'my-app',
template: `
<app-tab>
<div class="title" #title>
title!
</div>
@jiaming0708
jiaming0708 / 010_jshint.js
Created February 25, 2017 10:57
cordova hooks
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var jshint = require('jshint').JSHINT;
var async = require('async');
var recursiveFolderSearch = true;
var foldersToProcess = [
'js'
];
@jiaming0708
jiaming0708 / enterToTab.js
Created February 25, 2017 11:34
angularJS directive
angular.module('directive', [])
.directive('enterToTab', function () {
return {
restrict: 'A',
scope: {
afterEvent: '&afterEnter',
beforeEvent: '&keydown'
},
link: function (scope, element, attrs) {
element.bind('keydown', function (event) {
@jiaming0708
jiaming0708 / i18n-provider_v1.ts
Last active May 4, 2017 09:45
angular i18n provider
function getTranslationProviders():Promise<CompilerOptions[]>{
const locale = 'zh-TW';
const PROVIDERS = [{provide: LOCALE_ID, useValue: locale}];
return System.import(`raw-loader!./locale/messages.${locale}.xlf`)
.then(
(translations: string) =>
[{provide: TRANSLATIONS, useValue: translations},
{provide: TRANSLATIONS_FORMAT, useValue: 'xlf'},
...PROVIDERS])
.catch(() => PROVIDERS); // ignore if file not found
var create = Observable.create(observer => {
setTimeout(function () {
observer.next(3)
}, 100);
setTimeout(function () {
observer.next(4)
}, 200);
});
Private Function CheckCompanyExist(comp As String, mac As String) As Boolean
Dim result As Boolean
Dim ADOcn As New ADODB.Connection
Dim ADOrt As New ADODB.Recordset
Dim strCn As String
Dim strSQL As String
strCn = "Provider=SQLOLEDB;Server=eshclouds-license******;Database=License;Uid=******;Pwd=*****;"
class Producer {
listeners = [];
constructor() {
}
addListener(listener) {
if(typeof listener === 'function') {
this.listeners.push(listener)
} else {
@jiaming0708
jiaming0708 / decoractor.ts
Created August 29, 2017 14:11
decoractor
function f() {
console.log("f(): evaluated");
return function (target, propertyKey: string, descriptor: PropertyDescriptor) {
console.log("f(): called");
}
}
function g() {
console.log("g(): evaluated");
return function (target, propertyKey: string, descriptor: PropertyDescriptor) {
@jiaming0708
jiaming0708 / APIConfig.ts
Created September 27, 2017 02:04
ionic proxy config
import { Platform } from 'ionic-angular';
import { InjectionToken, Injectable } from "@angular/core";
export let APP_CONFIG = new InjectionToken<string>('apiConfig');
export function APIConfig(plat: Platform) {
const _browser = '/api'; // reverse proxy
const _device = 'http://192.168.0.100/api';
return plat.is('core') ? _browser : _device;