Logo
Explore Help
Sign In
iSharkFly-Docs/angular-docs-cn
1
0
Fork 0
You've already forked angular-docs-cn
Code Issues Pull Requests Actions Packages Projects Releases Wiki Activity
angular-docs-cn/aio/content/examples/toh-pt4/src/app/message.service.ts

17 lines
247 B
TypeScript
Raw Permalink Normal View History

docs(aio): update ToH for CLI (#19811)
2017-11-06 19:02:18 +01:00
import { Injectable } from '@angular/core';
docs: recommend best practice for providers (#22934) PR Close #22934
2018-03-22 10:37:50 -07:00
@Injectable({
providedIn: 'root',
})
docs(aio): update ToH for CLI (#19811)
2017-11-06 19:02:18 +01:00
export class MessageService {
messages: string[] = [];
add(message: string) {
this.messages.push(message);
}
clear() {
docs(aio): Clearing array with [] (#20369) (#20395) Clearing array with setting length to 0 replaced with [] for being short and marginally efficient. For reference: [] is turned into a sequence of around 15 machine instructions on x64 (if bump pointer allocation succeeds), whereas a.length=0 is a C++ runtime function call, which requires 10-100x as many instructions. Benedikt Meurer PR Close #20395
2017-11-13 21:13:37 +05:30
this.messages = [];
docs(aio): update ToH for CLI (#19811)
2017-11-06 19:02:18 +01:00
}
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.8 Page: 205ms Template: 10ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API