Skip to content

Instantly share code, notes, and snippets.

View techindepth's full-sized avatar
👋

ANISH ANTONY techindepth

👋
View GitHub Profile
@techindepth
techindepth / angular-component.ts
Last active November 5, 2018 16:44
angular component example
@Component({
selector: 'my-app',
template: `
<h1>Testing the Angular Component</h1>
`,
})
class TestComponent {
counter = 0;
name = 'Angular 2'
@techindepth
techindepth / angular-directive.ts
Created November 5, 2018 16:46
Angular Directive Example
import {Directive, ElementRef} from 'angular2/angular2';
@Directive({
selector: "[link]",
hostListeners: {
'mouseenter': 'onMouseEnter()',
'mouseleave': 'onMouseLeave()'
}
})
class LinkHighlight {
$scope.$watch('myValue', function(newValue, oldValue) {
//update the DOM with newValue
});
var start,
time = 0;
timer = performance ? performance.now : Date.now;
// start timer
function doSomething() {
console.log('Async task');
}
// start timer
start = timer();
foo();
setTimeout(doSomething, 2000);
bar();
baz();
// stop timer
function main() {
foo();
setTimeout(doSomething, 2000);
bar();
baz();
}
zone.run(main);
function main() {
foo();
setTimeout(doSomething, 2000);
bar();
baz();
}
var myZoneSpec = {
beforeTask: function () {
@Component({
selector: 'progress-bar',
template: `
<h3>Progress: {{progress}}</h3>
<button (click)="processWithinAngularZone()">
@Component({
selector: 'progress-bar',
template: `
<h3>Progress: {{progress}}</h3>
<button (click)="processWithinAngularZone()">
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { EagerComponent } from './eager.component';
import { routing } from './app.routing';
@NgModule({
imports: [
BrowserModule,