Remember: An Angular2 App requires at least one module and component to get started.
Is app.component.ts necessary?
Not necessarily.
It's just the name of a .ts file, which can be any other component. However, you do need at least one module and component to start an Angular2 App.
Here are some key points to understand:
main.ts
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module'; //<<<==== importing AppModule class from app.module.ts file
const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule); //<<<===bootstrapping our AppModule here
app.module.ts // name of .ts file
//contents are important as it contains @NgModule({}) decorator.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { SomeComponent } from './some.component';
//<<<==== importing SomeComponent class from some.component.ts file to bootstrap it.
@NgModule({
imports: [ BrowserModule],
declarations: [ SomeComponent ],
bootstrap: [ SomeComponent ] //<<<===bootstraping/initializing SomeComponent as our first component.
})
export class AppModule { } //<<<====imported AppModule (contains @NgModule decorator) in main.ts for bootstrapping this class with @NgModule() decorator.
some.component.ts //name of .ts file
import { Component } from '@angular/core';
import {UserService} from '../shared/shared.service';
@Component({
selector: 'my-app', //<<<===make sure this matches with custom HTML tag used in index.html
template: `<h1>Angular2</h1>
`
})
export class SomeComponent {}