Angular study notes (version 6 small notes)

1. The path of lazyload has become a relative path, but if you use ng update, you still don't need to modify it, cli config seems to be able to adjust the writing method that supports absolute paths. 

const routes: Routes = [
  { path: '', loadChildren: './home/home.module#HomeModule' },
];

 

2. Service can declare its usage place through decorator, no need to register through ngModule providers.

import { Injectable } from '@angular/core';
@Injectable({ providedIn:
'root' }) export class AbcService { constructor() { } }

The benefit of this conversion is said to be for tree shake. 

In fact, this is fine, because ng's Service written in module providers is originally global, so the definition is easier to understand. 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325299814&siteId=291194637