Open seongbin9786 opened 5 months ago
Render the output below when the input below presented.
Requirements can be changed along with the progress of development of this issue.
bootstrapModule(module);
myComponent#callCounter <-> {{callCounter}}
myComponent#handleClick <-> (click)="handleClick($event)"
Rendered HTML
<body> <my-component> <div> <div>hello world</div> <span>for the {{callCounter}} times!</span> <button (click)="handleClick()">Click me to raise the number!</button> </div> </my-component> <script src="./dist/main.js"></script> </body>
index.html
<body> <my-component></my-component> <script src="./dist/main.js"></script> </body>
boostrap call
bootstrapModule(MyModule);
Component
@Component({ selector: 'my-component', template: ` <div> <div>hello world</div> <span>for the {{callCounter}} times!</span> </div> `, }) class MyComponent { callCounter: number = 0; constructor(private myService: MyService) { } handleClick() { this.callCounter++; console.log(`handle click for ${this.callCounter} times!`); this.myService.doSomeService(); } }
Service
@Injectable class MyService { doSomeService() { console.log('doing service!'); } }
NgModule
@NgModule({ declarations: [ MyComponent ], imports: [], providers: [ MyService ], bootstrap: [ MyComponent ], }) export class MyModule {}
/packages/compiler-cli/src/ngtsc/program.ts
/packages/compiler/src/render3/r3_template_transform.ts
Render the output below when the input below presented.
Requirements
bootstrapModule(module);
called.bootstrapModule(module);
called.myComponent#callCounter <-> {{callCounter}}
) to HTML when the component is first rendered.myComponent#handleClick <-> (click)="handleClick($event)"
).Output
Rendered HTML
Input Source Code
index.html
boostrap call
Component
Service
NgModule