Skip to content

Instantly share code, notes, and snippets.

View pankajparkar's full-sized avatar
👨‍💻
Coding

Pankaj Parkar pankajparkar

👨‍💻
Coding
View GitHub Profile
@pankajparkar
pankajparkar / tab.html
Created April 1, 2019 02:40
ControllerAs pattern
<div class="tab-pane" ng-show="tab.details.selected">
<h4>{{tab.details.title}}</h4>
<div ng-transclude></div>
</div>
@pankajparkar
pankajparkar / controller-as-directive.js
Created April 1, 2019 02:38
Directive with controller as
.directive('tabs', function() {
return {
restrict: 'E',
transclude: true,
scope: {},
controllerAs: 'tabs',
controller: [function TabsController() {
var tabs = this;
var panes = tabs.panes = []
tabs.select = function(pane) {
<div class="tab-pane" ng-show="details.selected">
<h4>{{details.title}}</h4>
<div ng-transclude></div>
</div>
@pankajparkar
pankajparkar / tab-directive-with-$scope.js
Last active March 31, 2019 11:20
Tabs Directive with $scope
.directive('tabs', function() {
return {
restrict: 'E',
transclude: true,
scope: { },
controller: ['$scope', function TabsController($scope) {
var panes = $scope.panes = []
$scope.select = function(pane) {
angular.forEach(panes, function(p) {
p.selected = false;
@pankajparkar
pankajparkar / require-option.js
Created March 30, 2019 20:17
Require option in directive API demo.
.directive('myDirective', function () {
return {
restrict: 'AECM',
require: 'ngModel',
link: function (scope, element, attrs, ctrl) {
console.log('ngModelController', ctrl)
}
}
})
@pankajparkar
pankajparkar / highlight.ts
Created March 1, 2019 03:24
Highlight code
ngAfterViewChecked(): void {
this.zone.runOutsideAngular(() => {
this.el.nativeElement.classList.add('highlight')
setTimeout(() => {
this.el.nativeElement.classList.remove('highlight')
}, 1500)
})
}
@pankajparkar
pankajparkar / app.component.html
Created February 27, 2019 18:00
Angular simple component
<span>
{{title}}
</span>
<button (click)="title='Changed'">
Change Title
</button>
@pankajparkar
pankajparkar / tick_implementation.js
Created February 27, 2019 14:03
Simplistic tick implementation
tick(): void {
try {
this._views.forEach((view) => view.detectChanges());
if (this._enforceNoNewChanges) {
this._views.forEach((view) => view.checkNoChanges());
}
} catch (e) {
...
} finally {
...
@pankajparkar
pankajparkar / zone_tick.js
Last active February 27, 2019 14:04
tick
this._zone.onMicrotaskEmpty.subscribe({
next: () => {
this._zone.run(() => {
this.tick();
});
}}
);
@pankajparkar
pankajparkar / zonejs.js
Created February 27, 2019 13:08
zonejs
var myZoneSpec = {
beforeTask: function () {
console.log('Before task');
},
afterTask: function () {
console.log('After task');
}
};
var myZone = zone.fork(myZoneSpec);