Skip to content

Instantly share code, notes, and snippets.

@eneajaho
Last active September 28, 2022 16:02
Angular component with pipe (generated code)
class PlusOnePipe {
transform(value) { return value + 1; }
}
PlusOnePipe.ɵfac = function PlusOnePipe_Factory(t) {
return new (t || PlusOnePipe)();
};
PlusOnePipe.ɵpipe = ɵɵdefinePipe({
name: "plusOne",
type: PlusOnePipe,
pure: true,
standalone: true
});
class AppComponent { constructor() { this.count = 0; } }
AppComponent.ɵfac = function AppComponent_Factory(t) {
return new (t || AppComponent)();
};
AppComponent.ɵcmp = /*@__PURE__*/ ɵɵdefineComponent({
type: AppComponent,
selectors: [["app-root"]],
standalone: true,
features: [ɵɵStandaloneFeature],
decls: 5,
vars: 3,
consts: [[3, "click"]],
template: function AppComponent_Template(rf, ctx) {
if (rf & 1) {
ɵɵelementStart(0, "div");
ɵɵtext(1);
ɵɵpipe(2, "plusOne");
ɵɵelementEnd();
ɵɵelementStart(3, "button", 0);
ɵɵlistener("click", function AppComponent_Template_button_click_3_listener() {
return ctx.count = ctx.count + 1;
});
ɵɵtext(4, "Increase");
ɵɵelementEnd();
} if (rf & 2) {
ɵɵadvance(1);
ɵɵtextInterpolate(ɵɵpipeBind1(2, 1, ctx.count));
}
},
dependencies: [PlusOnePipe],
encapsulation: 2
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment